[manpage_begin textmenu n 1]
[titledesc {Create and manipulate a [widget textmenu] megawidgets}]
[require Tcl 8.5]
[require Snit 2.3.2]

[description]

[widget textmenu] pathName [opt options]
[keywords textmenu]
[section {STANDARD OPTIONS}]
[example_begin][cmd {
-activebackground     -borderwidth         -foreground
-activeborderwidth    -cursor              -relief           
-activeforeground     -disabledforeground  -takefocus
-background           -font} ]
[example_end]
[para]

See the options manual entry for details on the standard options.

[section {WIDGET-SPECIFIC OPTIONS}]
[example_begin]
Command-Line Name:[cmd -postcommand]
Database Name:  postCommand
Database Class: Command
[example_end]

              If this option is specified then it provides a Tcl command to
              execute each time the menu is posted.  The command is invoked by
              the post widget command before posting the menu.
[para]
       Command-Line Name:-selectcolor
       Database Name:  selectColor
       Database Class: Background

              For menu entries that are check buttons or radio buttons, this
              option specifies the color to display in the indicator when the
              check button or radio button is selected.

       Command-Line Name:-tearoff
       Database Name:  tearOff
       Database Class: TearOff

              This option must have a proper boolean value, which specifies
              whether or not the menu should include a tear-off entry at the
              top.  If so, it will exist as entry 0 of the menu and the other
              entries will number starting at 1.  The default menu bindings
              arrange for the menu to be torn off when the tear-off entry is
              invoked.  This option is ignored under Aqua/Mac OS X, where
              menus cannot be torn off.

       Command-Line Name:-tearoffcommand
       Database Name:  tearOffCommand
       Database Class: TearOffCommand

              If this option has a non-empty value, then it specifies a Tcl
              command to invoke whenever the menu is torn off.  The actual
              command will consist of the value of this option, followed by a
              space, followed by the name of the menu window, followed by a
              space, followed by the name of the name of the torn off menu
              window.  For example, if the option's value is “a b” and menu
              .x.y is torn off to create a new menu .x.tearoff1, then the
              command “a b .x.y .x.tearoff1” will be invoked.  This option is
              ignored under Aqua/Mac OS X, where menus cannot be torn off.

       Command-Line Name:-title
       Database Name:  title
       Database Class: Title

              The string will be used to title the window created when this
              menu is torn off. If the title is NULL, then the window will
              have the title of the menubutton or the text of the cascade item
              from which this menu was invoked.

______________________________________________________________________________

INTRODUCTION

The textmenu command creates a new top-level or embedded window
(given by the pathName argument) and makes it into a menu widget.  That menu widget can either
       be used as a pop-up window or embedded into another widget.  Additional
       options, described above, may be specified on the command line or in
       the option database to configure aspects of the textmenu such as its colors
       and font.  The menu command returns its pathName argument.  At the time
       this command is invoked, there must not exist a window named pathName,
but pathName's parent must exist.

If the pathName argument is a top-level window a top-level menu is created
otherwise a embeddable window is created.
(The window is embedded by being the object of a pack or grid command.)

       A textmenu is a megawidget that displays a collection of one-line entries
       arranged in a column.  There exist several different types
       of entries, each with different properties.  Entries of different types
       may be combined in a single textmenu.  Textmenu entries are not the same as
       entry widgets.  In fact, textmenu entries are not even distinct widgets;
       the entire textmenu is one megawidget.

       Textmenu entries are displayed with up to three separate fields.  The main
       field is a label in the form of a text string, a bitmap, or an image,
controlled by the -label,!!!!
-bitmap, and -image options for the entry.!!!
The second field is an indention which is used to indent menu items
under the cascade entries.
  The third field is an
       indicator.  The indicator is present only for cascade, checkbutton or
       radiobutton entries.  It indicates whether the entry is selected or
       not, and is displayed to the left of the entry's string.

       In normal use, an entry becomes active (displays itself differently)
       whenever the mouse pointer is over the entry.  If a mouse button is
       released over the entry then the entry is invoked.  The effect of
       invocation is different for each type of entry; these effects are
described below in the sections on individual entries.

Textmenus are scrollable both horizontally and vertically.

   !!!!    Entries may be disabled, which causes their labels and accelerators to
       be displayed with dimmer colors.  The default menu bindings will not
       allow a disabled entry to be activated or invoked.  Disabled entries
       may be re-enabled, at which point it becomes possible to activate and
       invoke them again.  !!!!

   !!!    Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
       event is send to the menu. The active item can then be queried from the
       menu, and an action can be taken, such as setting context-sensitive
       help text for the entry.
   !!!
TYPES OF ENTRIES
   COMMAND ENTRIES
       The most common kind of menu entry is a command entry, which behaves
       much like a button widget.  When a command entry is invoked, a Tcl
       command is executed.  The Tcl command is specified with the -command
       option.

   SEPARATOR ENTRIES
       A separator is an entry that is displayed as a horizontal dividing
       line.  A separator may not be activated or invoked, and it has no
       behavior other than its display appearance.

   CHECKBUTTON ENTRIES
       A checkbutton menu entry behaves much like a checkbutton widget.  When
       it is invoked it toggles back and forth between the selected and
       deselected states.  When the entry is selected, a particular value is
       stored in a particular global variable (as determined by the -onvalue
       and -variable options for the entry);  when the entry is deselected
       another value (determined by the -offvalue option) is stored in the
       global variable.  An indicator box is displayed to the left of the
       label in a checkbutton entry.  If the entry is selected then the
       indicator's center is displayed in the color given by the -selectcolor
       option for the entry; otherwise the indicator's center is displayed in
       the background color for the menu.  If a -command option is specified
       for a checkbutton entry, then its value is evaluated as a Tcl command
       each time the entry is invoked;  this happens after toggling the
       entry's selected state.

   RADIOBUTTON ENTRIES
       A radiobutton menu entry behaves much like a radiobutton widget.
       Radiobutton entries are organized in groups of which only one entry may
       be selected at a time.  Whenever a particular entry becomes selected it
       stores a particular value into a particular global variable (as
       determined by the -value and -variable options for the entry).  This
       action causes any previously-selected entry in the same group to
       deselect itself.  Once an entry has become selected, any change to the
       entry's associated variable will cause the entry to deselect itself.
       Grouping of radiobutton entries is determined by their associated
       variables:  if two entries have the same associated variable then they
       are in the same group.  An indicator diamond is displayed to the left
       of the label in each radiobutton entry.  If the entry is selected then
       the indicator's center is displayed in the color given by the
       -selectcolor option for the entry; otherwise the indicator's center is
       displayed in the background color for the menu.  If a -command option
       is specified for a radiobutton entry, then its value is evaluated as a
       Tcl command each time the entry is invoked;  this happens after
       selecting the entry.

   CASCADE ENTRIES
       A cascade entry is one with an associated menu (determined by the -menu
       option).  Cascade entries allow the construction of cascading menus.
       The postcascade widget command can be used to post and unpost the
       associated menu just next to of the cascade entry.  The associated menu
       must be a child of the menu containing the cascade entry (this is
       needed in order for menu traversal to work correctly).

       A cascade entry posts its associated menu by invoking a Tcl command of
       the form
              menu post x y
       where menu is the path name of the associated menu, and x and y are the
       root-window coordinates of the upper-right corner of the cascade entry.
       On Unix, the lower-level menu is unposted by executing a Tcl command
       with the form
              menu unpost
       where menu is the name of the associated menu.  On other platforms, the
       platform's native code takes care of unposting the menu.

       If a -command option is specified for a cascade entry then it is
       evaluated as a Tcl command whenever the entry is invoked. This is not
       supported on Windows.

   TEAR-OFF ENTRIES
       A tear-off entry appears at the top of the menu if enabled with the
       -tearoff option.  It is not like other menu entries in that it cannot
       be created with the add widget command and cannot be deleted with the
       delete widget command.  When a tear-off entry is created it appears as
       a dashed line at the top of the menu.  Under the default bindings,
       invoking the tear-off entry causes a torn-off copy to be made of the
       menu and all of its submenus.
WIDGET COMMAND
       The textmenu command creates a new Tcl command whose name is pathName.
       This command may be used to invoke various operations on the widget.
       It has the following general form:
              pathName option ?arg arg ...?
       Option and the args determine the exact behavior of the command.

       Many of the widget commands for a menu take as one argument an
       indicator of which entry of the menu to operate on. These indicators
       are called indexes and may be specified in any of the following forms:

       active      Indicates the entry that is currently active.  If no entry
                   is active then this form is equivalent to none.  This form
                   may not be abbreviated.

       end         Indicates the bottommost entry in the menu.  If there are
                   no entries in the menu then this form is equivalent to
                   none.  This form may not be abbreviated.

       last        Same as end.

       none        Indicates “no entry at all”; this is used most commonly
                   with the activate option to deactivate all the entries in
                   the menu.  In most cases the specification of none causes
                   nothing to happen in the widget command.  This form may not
                   be abbreviated.

       @number     In this form, number is treated as a y-coordinate in the
                   menu's window;  the entry closest to that y-coordinate is
                   used.  For example, “@0” indicates the top-most entry in
                   the window.

       number      Specifies the entry numerically, where 0 corresponds to the
                   top-most entry of the menu, 1 to the entry below it, and so
                   on.

       pattern     If the index does not satisfy one of the above forms then
                   this form is used.  Pattern is pattern-matched against the
                   label of each entry in the menu, in order from the top
                   down, until a matching entry is found.  The rules of string
                   match are used.

       If the index could match more than one of the above forms, then the
       form earlier in the above list takes precedence.

       The following widget commands are possible for menu widgets:

       pathName activate index
              Change the state of the entry indicated by index to active and
              redisplay it using its active colors.  Any previously-active
              entry is deactivated.  If index is specified as none, or if the
              specified entry is disabled, then the menu ends up with no
active entry.  Returns an empty string. The active state is
textmenu wide, i.e. only one entry in the collective menu and submenus may be active.

       pathName add type ?option value option value ...?
              Add a new entry to the bottom of the menu.  The new entry's type
              is given by type and must be one of cascade, checkbutton,
              command, radiobutton, or separator, or a unique abbreviation of
              one of the above.  If additional arguments are present, they
              specify the options listed in the MENU ENTRY OPTIONS section
              below.  The add widget command returns an empty string.

       pathName cget option
              Returns the current value of the configuration option given by
              option.  Option may have any of the values accepted by the menu
              command.

       pathName clone newPathname ?cloneType?
              Makes a clone of the current menu named newPathName. This clone
              is a menu in its own right, but any changes to the clone are
              propagated to the original menu and vice versa. cloneType can be
              normal, menubar, or tearoff. Should not normally be called
              outside of the Tk library. See the CLONES section for more
              information.

       pathName configure ?option? ?value option value ...?
              Query or modify the configuration options of the widget.  If no
              option is specified, returns a list describing all of the
              available options for pathName (see Tk_ConfigureInfo for
              information on the format of this list).  If option is specified
              with no value, then the command returns a list describing the
              one named option (this list will be identical to the
              corresponding sublist of the value returned if no option is
              specified).  If one or more option-value pairs are specified,
              then the command modifies the given widget option(s) to have the
              given value(s);  in this case the command returns an empty
              string.  Option may have any of the values accepted by the menu
              command.

       pathName delete index1 ?index2?
              Delete all of the menu entries between index1 and index2
              inclusive.  If index2 is omitted then it defaults to index1.
              Attempts to delete a tear-off menu entry are ignored (instead,
              you should change the -tearoff option to remove the tear-off
              entry).

       pathName entrycget index option
              Returns the current value of a configuration option for the
              entry given by index.  Option may have any of the names
              described in the MENU ENTRY OPTIONS section below.

       pathName entryconfigure index ?options...?
              This command is similar to the configure command, except that it
              applies to the options for an individual entry, whereas
              configure applies to the options for the menu as a whole.
              Options may have any of the values described in the MENU ENTRY
              OPTIONS section below.  If options are specified, options are
              modified as indicated in the command and the command returns an
              empty string.  If no options are specified, returns a list
              describing the current options for entry index (see
              Tk_ConfigureInfo for information on the format of this list).

       pathName index index
              Returns the numerical index corresponding to index, or none if
              index was specified as none.

       pathName insert index type ?option value option value ...?
              Same as the add widget command except that it inserts the new
              entry just before the entry given by index, instead of appending
              to the end of the menu.  The type, option, and value arguments
              have the same interpretation as for the add widget command.  It
              is not possible to insert new menu entries before the tear-off
              entry, if the menu has one.

       pathName invoke index
              Invoke the action of the menu entry.  See the sections on the
              individual entries above for details on what happens.  If the
              menu entry is disabled then nothing happens.  If the entry has a
              command associated with it then the result of that command is
              returned as the result of the invoke widget command.  Otherwise
              the result is an empty string.  Note:  invoking a menu entry
              does not automatically unpost the menu;  the default bindings
              normally take care of this before invoking the invoke widget
              command.

       pathName post x y ?index?
              Arrange for the menu to be displayed on the screen at the root-
              window coordinates given by x and y.  If an index is specified
              the menu will be located so that the entry with that index is
              displayed at the point.  These coordinates are adjusted if
              necessary to guarantee that the entire menu is visible on the
              screen.  This command normally returns an empty string.  If the
              -postcommand option has been specified, then its value is
              executed as a Tcl script before posting the menu and the result
              of that script is returned as the result of the post widget
              command.  If an error returns while executing the command, then
              the error is returned without posting the menu.

       pathName postcascade index
              Posts the submenu associated with the cascade entry given by
              index, and unposts any previously posted submenu.  If index does
              not correspond to a cascade entry, or if pathName is not posted,
              the command has no effect except to unpost any currently posted
              submenu.

       pathName type index
              Returns the type of the menu entry given by index.  This is the
              type argument passed to the add or insert widget command when
              the entry was created, such as command or separator, or tearoff
              for a tear-off entry.

       pathName unpost
              Unmap the window so that it is no longer displayed.  If a lower-
              level cascaded menu is posted, unpost that menu.  Returns an
              empty string. This subcommand does not work on Windows and the
              Macintosh, as those platforms have their own way of unposting
              menus.
!!!
       pathName xposition index
              Returns a decimal string giving the x-coordinate within the menu
              window of the leftmost pixel in the entry specified by index.

       pathName yposition index
              Returns a decimal string giving the y-coordinate within the menu
              window of the topmost pixel in the entry specified by index.
!!!
     pathName xview option args
              This command is used to query and change the horizontal position
              of the text in the widget's window. It can take any of the
              following forms:

              pathName xview
                     Returns a list containing two elements. Each element is a
                     real fraction between 0 and 1; together they describe the
                     portion of the document's horizontal span that is visible
                     in the window. For example, if the first element is .2
                     and the second element is .6, 20% of the text is off-
                     screen to the left, the middle 40% is visible in the
                     window, and 40% of the text is off-screen to the right.
                     The fractions refer only to the lines that are actually
                     visible in the window: if the lines in the window are all
                     very short, so that they are entirely visible, the
                     returned fractions will be 0 and 1, even if there are
                     other lines in the text that are much wider than the
                     window.  These are the same values passed to scrollbars
                     via the -xscrollcommand option.

              pathName xview moveto fraction
                     Adjusts the view in the window so that fraction of the
                     horizontal span of the text is off-screen to the left.
                     Fraction is a fraction between 0 and 1.

              pathName xview scroll number what
                     This command shifts the view in the window left or right
                     according to number and what. What must be units, pages
                     or pixels. If what is units or pages then number must be
                     an integer, otherwise number may be specified in any of
                     the forms acceptable to Tk_GetPixels, such as “2.0c” or
                     “1i” (the result is rounded to the nearest integer value.
                     If no units are given, pixels are assumed). If what is
                     units, the view adjusts left or right by number average-
                     width characters on the display; if it is pages then the
                     view adjusts by number screenfuls; if it is pixels then
                     the view adjusts by number pixels. If number is negative
                     then characters farther to the left become visible; if it
                     is positive then characters farther to the right become
                     visible.

       pathName yview ?args?
              This command is used to query and change the vertical position
              of the text in the widget's window. It can take any of the
              following forms:

              pathName yview
                     Returns a list containing two elements, both of which are
                     real fractions between 0 and 1. The first element gives
                     the position of the first visible pixel of the first
                     character (or image, etc) in the top line in the window,
                     relative to the text as a whole (0.5 means it is halfway
                     through the text, for example). The second element gives
                     the position of the first pixel just after the last
                     visible one in the bottom line of the window, relative to
                     the text as a whole. These are the same values passed to
                     scrollbars via the -yscrollcommand option.

              pathName yview moveto fraction
                     Adjusts the view in the window so that the pixel given by
                     fraction appears at the top of the top line of the
                     window. Fraction is a fraction between 0 and 1; 0
                     indicates the first pixel of the first character in the
                     text, 0.33 indicates the pixel that is one-third the way
                     through the text; and so on. Values close to 1 will
                     indicate values close to the last pixel in the text (1
                     actually refers to one pixel beyond the last pixel), but
                     in such cases the widget will never scroll beyond the
                     last pixel, and so a value of 1 will effectively be
                     rounded back to whatever fraction ensures the last pixel
                     is at the bottom of the window, and some other pixel is
                     at the top.

              pathName yview scroll number what
                     This command adjust the view in the window up or down
                     according to number and what. What must be units, pages
                     or pixels. If what is units or pages then number must be
                     an integer, otherwise number may be specified in any of
                     the forms acceptable to Tk_GetPixels, such as “2.0c” or
                     “1i” (the result is rounded to the nearest integer value.
                     If no units are given, pixels are assumed). If what is
                     units, the view adjusts up or down by number lines on the
                     display; if it is pages then the view adjusts by number
                     screenfuls; if it is pixels then the view adjusts by
                     number pixels. If number is negative then earlier
                     positions in the text become visible; if it is positive
                     then later positions in the text become visible.

              pathName yview ?-pickplace? index
                     Changes the view in the widget's window to make index
                     visible. If the -pickplace option is not specified then
                     index will appear at the top of the window. If -pickplace
                     is specified then the widget chooses where index appears
                     in the window:



In the following "pathName" may refer to the toplevel menu or to cascades.

pathName postcascade index ?unpost subsubs?

As per the "menu" command:  Conditionally unposts any currently posted submenu.
              And then posts the submenu associated with the cascade entry 
              given by index. If index
              does not correspond to a cascade entry, or if pathName is not posted,
the command has no other effect.
Submenus are unposted only if the option "-muptipleopen" is false.
If submenus of these unposted submenus are posted, they will be reposted when the
containing submenu is reposted unless <unpost subsubs> is true. Returns an empty
string.

pathName unpost ?unpost subs?
  
If a lower-level cascaded menus are posted, unpost those menus.  
 lower-level cascades that were posted will again be posted when the menu is
reposted unless <unpost subs> is true. If "pathName" refers to the toplevel menu
that window will be cleared. If the menu is a toplevel window and is not 'tornoff'
it will be unmaped so that it is no longer displayed. Returns an empty string. 

[manpage_end]
