Seth Woolley's Man Viewer

Manual for menu - man n menu

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

menu(3x,n,n tk_menuSetFocus)(n)                      Tk Built-In Commands                      menu(3x,n,n tk_menuSetFocus)(n)



NAME
       menu(3x,n,n tk_menuSetFocus), tk_menuSetFocus - Create and manipulate menu(3x,n,n tk_menuSetFocus) widgets

SYNOPSIS
       menu(3x,n,n tk_menuSetFocus) pathName ?options?
       tk_menuSetFocus pathName
       -activebackground   -borderwidth        -foreground
       -activeborderwidth  -cursor        -relief
       -activeforeground   -disabledforeground -takefocus
       -background    -font


WIDGET-SPECIFIC OPTIONS
       If  this  option is specified then it provides a Tcl command to execute
       each time(1,2,n) the menu(3x,n,n tk_menuSetFocus) is posted.  The command is invoked by the post  wid-
       get  command before posting the menu. Note that in(1,8) 8.0 on Macintosh and
       Windows, all commands in(1,8) a menu(3x,n,n tk_menuSetFocus) systems are  executed  before  any  are
       posted.  This  is  due  to the limitations in(1,8) the individual platforms'
       menu(3x,n,n tk_menuSetFocus) managers.  For menu(3x,n,n tk_menuSetFocus) entries that are check buttons or  radio  but-
       tons,  this option specifies the color to display in(1,8) the indicator when
       the check button or radio button is selected.  This option must have  a
       proper  boolean  value,  which specifies whether or not the menu(3x,n,n tk_menuSetFocus) should
       include a tear-off entry at the top.  If so, it will exist as  entry  0
       of  the  menu(3x,n,n tk_menuSetFocus)  and  the  other  entries will number starting at 1.  The
       default menu(3x,n,n tk_menuSetFocus) bindings arrange for the menu(3x,n,n tk_menuSetFocus) to  be  torn  off  when  the
       tear-off  entry is invoked.  If this option has a non-empty value, then
       it specifies a Tcl command to invoke whenever the  menu(3x,n,n tk_menuSetFocus)  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(3x,n,n tk_menuSetFocus)  window,  followed  by  a
       space,  followed  by  the name of the name of the torn off menu(3x,n,n tk_menuSetFocus) window.
       For example, if(3,n) the option's is ``a b'' and menu(3x,n,n tk_menuSetFocus) .x.y is  torn  off  to
       create   a   new   menu(3x,n,n tk_menuSetFocus)  .x.tearoff1,  then  the  command  ``a  b  .x.y
       .x.tearoff1'' will be invoked.  The string(3,n) will be used  to  title  the
       window  created  when this menu(3x,n,n tk_menuSetFocus) 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(3x,n,n tk_menuSetFocus) was invoked.  This option can be one
       of menubar, tearoff, or normal, and is set(7,n,1 builtins) when the  menu(3x,n,n tk_menuSetFocus)  is  created.
       While  the string(3,n) returned by the configuration database will change if(3,n)
       this option is changed, this does not affect the menu(3x,n,n tk_menuSetFocus)  widget's  behav-
       ior. This is used by the cloning mechanism and is not normally set(7,n,1 builtins) out-
       side of the Tk library.


INTRODUCTION
       The menu(3x,n,n tk_menuSetFocus) command creates a new top-level window (given by the  pathName
       argument)  and  makes  it  into  a  menu(3x,n,n tk_menuSetFocus)  widget.   Additional options,
       described above, may be specified on the command line or in(1,8) the  option
       database  to configure aspects of the menu(3x,n,n tk_menuSetFocus) such as its colors and font.
       The menu(3x,n,n tk_menuSetFocus) command returns its pathName argument.  At the time(1,2,n) this  com-
       mand  is  invoked,  there  must  not exist a window named(5,8) pathName, but
       pathName's parent must exist.

       A menu(3x,n,n tk_menuSetFocus) is a widget that  displays  a  collection  of  one-line  entries
       arranged  in(1,8)  one or more columns.  There exist several different types
       of entries, each with different properties.  Entries of different types
       may  be  combined  in(1,8)  a single menu.  Menu entries are not the same as
       entry widgets.  In fact, menu(3x,n,n tk_menuSetFocus) entries are not  even  distinct  widgets;
       the entire menu(3x,n,n tk_menuSetFocus) is one widget.

       Menu  entries are displayed with up to three separate fields.  The main
       field is a label in(1,8) the form of a text string(3,n), a bitmap, or  an  image,
       controlled  by  the  -label, -bitmap, and -image options for the entry.
       If the  -accelerator option is specified for an  entry  then  a  second
       textual  field is displayed to the right of the label.  The accelerator
       typically describes a keystroke sequence  that  may  be  typed  in(1,8)  the
       application  to  cause the same result as invoking the menu(3x,n,n tk_menuSetFocus) entry.  The
       third field is an indicator.  The indicator is present only for  check-
       button  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 invo-
       cation is different for each type of entry; these effects are described
       below in(1,8) the sections on individual entries.

       Entries may be disabled, which causes their labels and accelerators  to
       be  displayed  with  dimmer colors.  The default menu(3x,n,n tk_menuSetFocus) 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(3x,n,n tk_menuSetFocus)'s active entry is  changed,  a  <<MenuSelect>>  virtual(5,8)
       event is send(2,n) to the menu. The active item can then be queried from the
       menu(3x,n,n tk_menuSetFocus), and an action can be taken,  such  as  setting  context-sensitive
       help text for the entry.


COMMAND ENTRIES
       The  most  common  kind of menu(3x,n,n tk_menuSetFocus) entry is a command entry, which behaves
       much like a button widget.  When a command entry is invoked, a Tcl com-
       mand  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(3x,n,n tk_menuSetFocus) entry behaves much like a checkbutton widget.   When
       it  is invoked it toggles back and forth between the selected and dese-
       lected states.  When the entry  is  selected,  a  particular  value  is
       stored  in(1,8)  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(1,8) the
       global variable.  An indicator box is displayed  to  the  left  of  the
       label  in(1,8) a checkbutton entry.  If the entry is selected then the indi-
       cator's center is displayed in(1,8) the  color  given  by  the  -selectcolor
       option  for the entry; otherwise the indicator's center is displayed in(1,8)
       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(1,2,n) the entry  is  invoked;   this  happens  after  toggling  the
       entry's selected state.


RADIOBUTTON ENTRIES
       A  radiobutton  menu(3x,n,n tk_menuSetFocus)  entry  behaves  much  like  a radiobutton widget.
       Radiobutton entries are organized in(1,8) 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  deter-
       mined  by the -value and -variable options for the entry).  This action
       causes any previously-selected entry in(1,8)  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(3,n)
       two entries have the same associated variable then they are in(1,8) the same
       group.   An  indicator diamond is displayed to the left of the label in(1,8)
       each radiobutton entry.  If the entry is selected then the  indicator's
       center  is  displayed in(1,8) the color given by the -selectcolor option for
       the entry; otherwise the indicator's center is displayed in(1,8)  the  back-
       ground  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(1,2,n) the entry is invoked;  this happens after selecting the entry.


CASCADE ENTRIES
       A cascade entry is one with an associated menu(3x,n,n tk_menuSetFocus) (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 asso-
       ciated menu(3x,n,n tk_menuSetFocus) just next to of the cascade  entry.   The  associated  menu(3x,n,n tk_menuSetFocus)
       must  be  a  child  of  the  menu(3x,n,n tk_menuSetFocus) containing the cascade entry (this is
       needed in(1,8) order for menu(3x,n,n tk_menuSetFocus) traversal to work correctly).

       A cascade entry posts its associated menu(3x,n,n tk_menuSetFocus) by invoking a Tcl command  of
       the  form  menu(3x,n,n tk_menuSetFocus)  post x y where menu(3x,n,n tk_menuSetFocus) is the path name of the associated
       menu(3x,n,n tk_menuSetFocus), and x and y are the root-window coordinates  of  the  upper-right
       corner of the cascade entry.  On Unix, the lower-level menu(3x,n,n tk_menuSetFocus) is unposted
       by executing a Tcl command with the form menu(3x,n,n tk_menuSetFocus) unpost where menu(3x,n,n tk_menuSetFocus) 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 evalu-
       ated  as  a Tcl command whenever the entry is invoked. This is not sup-
       ported on Windows.


TEAR-OFF ENTRIES
       A tear-off entry appears at the top of the menu(3x,n,n tk_menuSetFocus)  if(3,n)  enabled  with  the
       tearOff option.  It is not like other menu(3x,n,n tk_menuSetFocus) entries in(1,8) 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(3x,n,n tk_menuSetFocus) and all of its submenus.


MENUBARS
       Any menu(3x,n,n tk_menuSetFocus) can be set(7,n,1 builtins) as a menubar for a toplevel  window  (see  toplevel
       command  for  syntax).  On  the  Macintosh, whenever the toplevel is in(1,8)
       front, this menu(3x,n,n tk_menuSetFocus)'s cascade items will appear in(1,8) the menubar across  the
       top of the main monitor. On Windows and Unix, this menu(3x,n,n tk_menuSetFocus)'s items will be
       displayed in(1,8) a menubar accross the top of the window. These menus  will
       behave  according  to  the interface guidelines of their platforms. For
       every menu(3x,n,n tk_menuSetFocus) set(7,n,1 builtins) as a menubar, a clone menu(3x,n,n tk_menuSetFocus) is made. See the CLONES  sec-
       tion for more information.

       As  noted, menubars may behave differently on different platforms.  One
       example of this concerns the handling of checkbuttons and  radiobuttons
       within  the  menu.  While it is permitted to put these menu(3x,n,n tk_menuSetFocus) elements on
       menubars, they may not be drawn with indicators on some platforms,  due
       to system restrictions.


SPECIAL MENUS IN MENUBARS
       Certain  menus  in(1,8)  a menubar will be treated specially.  On the Macin-
       tosh, access(2,5) to the special Apple and Help menus is provided.  On  Win-
       dows,  access(2,5) to the Windows System menu(3x,n,n tk_menuSetFocus) in(1,8) each window is provided. On
       X Windows, a special right-justified help  menu(3x,n,n tk_menuSetFocus)  is  provided.  In  all
       cases, these menus must be created with the command name of the menubar
       menu(3x,n,n tk_menuSetFocus) concatenated with  the  special  name.  So  for  a  menubar  named(5,8)
       .menubar,  on  the Macintosh, the special menus would be .menubar.apple
       and .menubar.help; on Windows, the special menu(3x,n,n tk_menuSetFocus) would be  .menubar.sys-
       tem; on X Windows, the help menu(3x,n,n tk_menuSetFocus) would be .menubar.help.

       When  Tk sees an Apple menu(3x,n,n tk_menuSetFocus) on the Macintosh, that menu(3x,n,n tk_menuSetFocus)'s contents make
       up the first items of the Apple menu(3x,n,n tk_menuSetFocus) on the screen whenever the  window
       containing  the menubar is in(1,8) front. The menu(3x,n,n tk_menuSetFocus) is the first one that the
       user sees and has a title which is an Apple logo.  After all of the Tk-
       defined  items,  the menu(3x,n,n tk_menuSetFocus) will have a separator, followed by all of the
       items in(1,8) the user's Apple Menu Items folder.  Since the System  uses  a
       different menu(3x,n,n tk_menuSetFocus) definition procedure for the Apple menu(3x,n,n tk_menuSetFocus) than Tk uses for
       its menus, and the system APIs do not fully support everything Tk tries
       to  do,  the  menu(3x,n,n tk_menuSetFocus)  item  will  only  have  its text displayed. No font
       attributes, images, bitmaps, or colors will be displayed. In  addition,
       a  menu(3x,n,n tk_menuSetFocus)  with  a  tearoff  item will have the tearoff item displayed as
       "(TearOff)".

       When Tk see a Help menu(3x,n,n tk_menuSetFocus) on  the  Macintosh,  the  menu(3x,n,n tk_menuSetFocus)'s  contents  are
       appended  to  the standard help menu(3x,n,n tk_menuSetFocus) on the right of the user's menubar
       whenever the user's menubar is in(1,8) front. The first items  in(1,8)  the  menu(3x,n,n tk_menuSetFocus)
       are  provided by Apple. Similar to the Apple Menu, cusomization in(1,8) this
       menu(3x,n,n tk_menuSetFocus) is limited to what the system provides.

       When Tk sees a System menu(3x,n,n tk_menuSetFocus) on Windows, its items are  appended  to  the
       system menu(3x,n,n tk_menuSetFocus) that the menubar is attached to. This menu(3x,n,n tk_menuSetFocus) has an icon rep-
       resenting a spacebar, and can be invoked with the mouse  or  by  typing
       Alt+Spacebar.  Due to limitations in(1,8) the Windows API, any font changes,
       colors, images, bitmaps, or tearoff images will not appear in(1,8) the  sys-
       tem menu.

       When  Tk  see a Help menu(3x,n,n tk_menuSetFocus) on X Windows, the menu(3x,n,n tk_menuSetFocus) is moved to be last in(1,8)
       the menubar and is right justified.


CLONES
       When a menu(3x,n,n tk_menuSetFocus) is set(7,n,1 builtins) as a menubar for a toplevel window, or when  a  menu(3x,n,n tk_menuSetFocus)
       is  torn  off, a clone of the menu(3x,n,n tk_menuSetFocus) is made. This clone is a menu(3x,n,n tk_menuSetFocus) widget
       in(1,8) its own right, but it is a child of the  original.  Changes  in(1,8)  the
       configuration of the original are reflected in(1,8) the clone. Additionally,
       any cascades that are pointed to are also cloned so that menu(3x,n,n tk_menuSetFocus) traversal
       will  work  right.  Clones  are  destroyed  when  either the tearoff or
       menubar goes away, or when the original menu(3x,n,n tk_menuSetFocus) is destroyed.


WIDGET COMMAND
       The menu(3x,n,n tk_menuSetFocus) 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(3x,n,n tk_menuSetFocus) take as one argument an indica-
       tor of which entry of the menu(3x,n,n tk_menuSetFocus) to operate  on.   These  indicators  are
       called indexes and may be specified in(1,8) any of the following forms:

       number      Specifies the entry numerically, where 0 corresponds to the
                   top-most entry of the menu(3x,n,n tk_menuSetFocus), 1 to the entry below it, and so
                   on.

       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(1,8) the menu.  If there are
                   no entries in(1,8) the menu(3x,n,n tk_menuSetFocus) 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(1,8)
                   the  menu.   In most cases the specification of none causes
                   nothing to happen in(1,8) the widget command.  This form may not
                   be abbreviated.

       @number     In  this  form,  number is treated as a y-coordinate in(1,8) the
                   menu(3x,n,n tk_menuSetFocus)'s window;  the entry closest to that  y-coordinate  is
                   used.   For example, ``@0'' indicates the top-most entry in(1,8)
                   the window.

       pattern     If the index doesn't satisfy one of the  above  forms  then
                   this  form is used.  Pattern is pattern-matched against the
                   label of each entry in(1,8) the menu(3x,n,n tk_menuSetFocus),  in(1,8)  order  from  the  top
                   down,  until  a  matching  entry  is  found.   The rules of
                   Tcl_StringMatch are used.

       The following widget commands are possible for menu(3x,n,n tk_menuSetFocus) 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(3,n)  the
              specified  entry  is  disabled,  then  the  menu(3x,n,n tk_menuSetFocus) ends up with no
              active entry.  Returns an empty string.

       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, com-
              mand, radiobutton, or separator, or a unique abbreviation of one
              of the above.  If additional arguments are present, they specify
              any of the following options:

              -activebackground value
                     Specifies a background color to use for  displaying  this
                     entry  when it is active.  If this option is specified as
                     an empty string(3,n) (the default), then the  activeBackground
                     option for the overall menu(3x,n,n tk_menuSetFocus) is used.  If the tk_strictMo-
                     tif variable has been set(7,n,1 builtins) to request strict Motif compli-
                     ance,  then  this  option  is ignored and the -background
                     option is used in(1,8) its place.  This option is  not  avail-
                     able for separator or tear-off entries.

              -activeforeground value
                     Specifies  a  foreground color to use for displaying this
                     entry when it is active.  If this option is specified  as
                     an  empty string(3,n) (the default), then the activeForeground
                     option for the overall menu(3x,n,n tk_menuSetFocus) is used.  This option is  not
                     available for separator or tear-off entries.

              -accelerator value
                     Specifies  a  string(3,n)  to display at the right side of the
                     menu(3x,n,n tk_menuSetFocus) entry.  Normally describes an accelerator  keystroke
                     sequence that may be typed to invoke the same function as
                     the menu(3x,n,n tk_menuSetFocus) entry.  This option is not available for separa-
                     tor or tear-off entries.

              -background value
                     Specifies  a  background color to use for displaying this
                     entry when it is in(1,8) the normal state (neither active  nor
                     disabled).   If  this  option  is  specified  as an empty
                     string(3,n) (the default), then the background option for  the
                     overall  menu(3x,n,n tk_menuSetFocus)  is used.  This option is not available for
                     separator or tear-off entries.

              -bitmap value
                     Specifies a bitmap to display in(1,8) the menu(3x,n,n tk_menuSetFocus)  instead  of  a
                     textual  label,  in(1,8)  any of the forms accepted by Tk_Get-
                     Bitmap.  This option overrides the -label option but  may
                     be  reset(1,7,1 tput) to an empty string(3,n) to enable a textual label to
                     be displayed.  If a -image option has been specified,  it
                     overrides -bitmap.  This option is not available for sep-
                     arator or tear-off entries.

              -columnbreak value
                     When this option is zero, the appears below the  previous
                     entry.  When  this option is one, the menu(3x,n,n tk_menuSetFocus) appears at the
                     top of a new column in(1,8) the menu.

              -command value
                     Specifies a Tcl command to execute when the menu(3x,n,n tk_menuSetFocus) entry is
                     invoked.    Not   available  for  separator  or  tear-off
                     entries.

              -compound value
                     Specifies whether the menu(3x,n,n tk_menuSetFocus) entry should display  both  an
                     image  and  text,  and  if(3,n)  so, where the image should be
                     placed relative to  the  text.   Valid  values  for  this
                     option  are  bottom,  center,  left, none, right and top.
                     The default value is none, meaning that the  button  will
                     display  either an image or text, depending on the values
                     of the -image and -bitmap options.

              -font value
                     Specifies the font to  use  when  drawing  the  label  or
                     accelerator  string(3,n)  in(1,8)  this  entry.   If this option is
                     specified as an empty string(3,n) (the default) then the  font
                     option  for the overall menu(3x,n,n tk_menuSetFocus) is used.  This option is not
                     available for separator or tear-off entries.

              -foreground value
                     Specifies a foreground color to use for  displaying  this
                     entry  when it is in(1,8) the normal state (neither active nor
                     disabled).  If this  option  is  specified  as  an  empty
                     string(3,n)  (the default), then the foreground option for the
                     overall menu(3x,n,n tk_menuSetFocus) is used.  This option is not  available  for
                     separator or tear-off entries.

              -hidemargin value
                     Specifies  whether  the  standard margins should be drawn
                     for this menu(3x,n,n tk_menuSetFocus) entry. This is useful when creating palette
                     with  images  in(1,8)  them,  i.e.,  color  palettes,  pattern
                     palettes, etc. 1 indicates that the margin for the  entry
                     is hidden; 0 means that the margin is used.

              -image value
                     Specifies  an  image  to display in(1,8) the menu(3x,n,n tk_menuSetFocus) instead of a
                     text string(3,n) or bitmap The image must have been created by
                     some  previous  invocation  of image create.  This option
                     overrides the -label and -bitmap options but may be reset(1,7,1 tput)
                     to an empty string(3,n) to enable a textual or bitmap label to
                     be displayed.  This option is not available for separator
                     or tear-off entries.

              -indicatoron value
                     Available  only  for checkbutton and radiobutton entries.
                     Value is a boolean that determines  whether  or  not  the
                     indicator should be displayed.

              -label value
                     Specifies  a string(3,n) to display as an identifying label in(1,8)
                     the menu(3x,n,n tk_menuSetFocus) entry.  Not available for separator or  tear-off
                     entries.

              -menu value
                     Available  only  for cascade entries.  Specifies the path
                     name of the submenu associated with this entry.  The sub-
                     menu(3x,n,n tk_menuSetFocus) must be a child of the menu.

              -offvalue value
                     Available  only  for  checkbutton entries.  Specifies the
                     value to store in(1,8) the entry's  associated  variable  when
                     the entry is deselected.

              -onvalue value
                     Available  only  for  checkbutton entries.  Specifies the
                     value to store in(1,8) the entry's  associated  variable  when
                     the entry is selected.

              -selectcolor value
                     Available  only  for checkbutton and radiobutton entries.
                     Specifies the color to display in(1,8) the indicator when  the
                     entry  is selected.  If the value is an empty string(3,n) (the
                     default) then the selectColor option for the menu(3x,n,n tk_menuSetFocus)  deter-
                     mines the indicator color.

              -selectimage value
                     Available  only  for checkbutton and radiobutton entries.
                     Specifies an image to display in(1,8) the entry (in(1,8)  place  of
                     the  -image  option)  when  it is selected.  Value is the
                     name of an image, which must have been  created  by  some
                     previous  invocation  of  image  create.   This option is
                     ignored unless the -image option has been specified.

              -state value
                     Specifies one of three states  for  the  entry:   normal,
                     active,  or  disabled.  In normal state the entry is dis-
                     played using the foreground option for the menu(3x,n,n tk_menuSetFocus)  and  the
                     background option from the entry or the menu.  The active
                     state is typically used when  the  pointer  is  over  the
                     entry.   In active state the entry is displayed using the
                     activeForeground option  for  the  menu(3x,n,n tk_menuSetFocus)  along  with  the
                     activebackground  option  from the entry.  Disabled state
                     means that the entry should be insensitive:  the  default
                     bindings will refuse to activate or invoke the entry.  In
                     this state the entry is displayed according to  the  dis-
                     abledForeground  option  for  the menu(3x,n,n tk_menuSetFocus) and the background
                     option from the entry.  This option is not available  for
                     separator entries.

              -underline value
                     Specifies  the  integer index of a character to underline
                     in(1,8) the entry.  This option is also queried by the default
                     bindings  and  used  to  implement keyboard traversal.  0
                     corresponds to the first character of the text  displayed
                     in(1,8)  the  entry, 1 to the next character, and so on.  If a
                     bitmap or image is  displayed  in(1,8)  the  entry  then  this
                     option is ignored.  This option is not available for sep-
                     arator or tear-off entries.

              -value value
                     Available only for radiobutton  entries.   Specifies  the
                     value  to  store  in(1,8) the entry's associated variable when
                     the entry is selected.  If an empty string(3,n) is  specified,
                     then  the  -label  option  for  the entry as the value to
                     store in(1,8) the variable.

              -variable value
                     Available only for checkbutton and  radiobutton  entries.
                     Specifies  the  name  of  a  global value to set(7,n,1 builtins) when the
                     entry is selected.  For checkbutton entries the  variable
                     is  also set(7,n,1 builtins) when the entry is deselected.  For radiobut-
                     ton entries, changing the variable causes the  currently-
                     selected entry to deselect itself.

              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(3x,n,n tk_menuSetFocus)
              command.

       pathName clone newPathname ?cloneType?
              Makes  a clone of the current menu(3x,n,n tk_menuSetFocus) named(5,8) newPathName. This clone
              is a menu(3x,n,n tk_menuSetFocus) in(1,8) its own right, but any changes  to  the  clone  are
              propogated to the original menu(3x,n,n tk_menuSetFocus) and vice versa. cloneType can be
              normal, menubar, or tearoff. Should not normally be called  out-
              side of the Tk library. See the CLONES section for more informa-
              tion.

       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 avail-
              able 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(5,8)
              option (this list will be identical to the corresponding sublist
              of the value returned if(3,n) 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(1,8)  this
              case  the  command returns an empty string.  Option may have any
              of the values accepted by the menu(3x,n,n tk_menuSetFocus) command.

       pathName delete index1 ?index2?
              Delete all of the menu(3x,n,n tk_menuSetFocus) entries between index1 and index2  inclu-
              sive.   If  index2  is  omitted  then  it  defaults  to  index1.
              Attempts to delete a tear-off menu(3x,n,n tk_menuSetFocus) 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 values
              accepted by the add widget command.

       pathName entryconfigure index ?options?
              This command is similar to the configure command, except that it
              applies  to the options for an individual entry, whereas config-
              ure applies to the options for the menu(3x,n,n tk_menuSetFocus) as a whole.  Options may
              have  any  of the values accepted by the add widget command.  If
              options are specified, options are modified as indicated in(1,8)  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(3,n)
              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(3x,n,n tk_menuSetFocus) entries before the tear-off
              entry, if(3,n) the menu(3x,n,n tk_menuSetFocus) has one.

       pathName invoke index
              Invoke the action of the menu(3x,n,n tk_menuSetFocus) entry.  See the  sections  on  the
              individual  entries  above  for details on what happens.  If the
              menu(3x,n,n tk_menuSetFocus) 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(3x,n,n tk_menuSetFocus) entry
              does not automatically unpost the menu(3x,n,n tk_menuSetFocus);   the  default  bindings
              normally  take  care  of  this before invoking the invoke widget
              command.

       pathName post x y
              Arrange for the menu(3x,n,n tk_menuSetFocus) to be displayed on the screen at the  root-
              window  coordinates  given  by  x  and y.  These coordinates are
              adjusted if(3,n) necessary to guarantee that the entire menu(3x,n,n tk_menuSetFocus) is visi-
              ble  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(3x,n,n tk_menuSetFocus) and
              the result of that script is returned as the result of the  post
              widget  command.   If  an error(8,n) returns while executing the com-
              mand, then the error(8,n) 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
              doesn't correspond to a cascade  entry,  or  if(3,n)  pathName  isn't
              posted, the command has no effect except to unpost any currently
              posted submenu.

       pathName type index
              Returns the type of the menu(3x,n,n tk_menuSetFocus) entry given by index.  This is  the
              type  argument  passed  to the add 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(3x,n,n tk_menuSetFocus) 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 yposition index
              Returns a decimal string(3,n) giving the y-coordinate within the menu(3x,n,n tk_menuSetFocus)
              window of the topmost pixel in(1,8) the entry specified by index.


MENU CONFIGURATIONS
       The default bindings support four different ways of using menus:

       Pulldown Menus in(1,8) Menubar
              This is the most command case. You create  a  menu(3x,n,n tk_menuSetFocus)  widget  that
              will  become  the menu(3x,n,n tk_menuSetFocus) bar. You then add cascade entries to this
              menu(3x,n,n tk_menuSetFocus), specifying the pull down menus you wish  to  use  in(1,8)  your
              menu(3x,n,n tk_menuSetFocus)  bar.  You  then create all of the pulldowns. Once you have
              done this, specify the  menu(3x,n,n tk_menuSetFocus)  using  the  -menu  option  of  the
              toplevel's  widget  command.  See  the toplevel manual entry for
              details.

       Pulldown Menus in(1,8) Menu Buttons
              This is the compatable way to do  menu(3x,n,n tk_menuSetFocus)  bars.   You  create  one
              menubutton  widget  for  each  top-level menu(3x,n,n tk_menuSetFocus), and typically you
              arrange a series of menubuttons in(1,8) a row in(1,8)  a  menubar  window.
              You  also  create the top-level menus and any cascaded submenus,
              and tie them together with -menu options in(1,8) menubuttons and cas-
              cade  menu(3x,n,n tk_menuSetFocus)  entries.   The top-level menu(3x,n,n tk_menuSetFocus) must be a child of the
              menubutton, and each submenu must be a child of  the  menu(3x,n,n tk_menuSetFocus)  that
              refers  to  it.   Once  you have done this, the default bindings
              will allow users(1,5) to traverse and invoke the tree  of  menus  via
              its menubutton;  see the menubutton manual entry for details.

       Popup Menus
              Popup  menus  typically post in(1,8) response to a mouse button press
              or keystroke.  You create the popup menus and any cascaded  sub-
              menus,  then  you call the tk_popup procedure at the appropriate
              time(1,2,n) to post the top-level menu.

       Option Menus
              An option menu(3x,n,n tk_menuSetFocus) consists of a menubutton with an associated  menu(3x,n,n tk_menuSetFocus)
              that  allows  you  to select(2,7,2 select_tut) one of several values.  The current
              value is displayed in(1,8) the menubutton and is  also  stored  in(1,8)  a
              global  variable.   Use  the  tk_optionMenu  procedure to create
              option menubuttons and their menus.

       Torn-off Menus
              You create a torn-off menu(3x,n,n tk_menuSetFocus) by invoking the tear-off entry at the
              top of an existing menu.  The default bindings will create a new
              menu(3x,n,n tk_menuSetFocus) that is a copy of the original menu(3x,n,n tk_menuSetFocus)  and  leave  it  perma-
              nently  posted as a top-level window.  The torn-off menu(3x,n,n tk_menuSetFocus) behaves
              just the same as the original menu.


DEFAULT BINDINGS
       Tk automatically creates class bindings for menus that  give  them  the
       following default behavior:

       [1]    When  the  mouse  enters  a menu(3x,n,n tk_menuSetFocus), the entry underneath the mouse
              cursor activates;  as the  mouse  moves  around  the  menu(3x,n,n tk_menuSetFocus),  the
              active entry changes to track the mouse.

       [2]    When  the  mouse  leaves  a  menu(3x,n,n tk_menuSetFocus) all of the entries in(1,8) the menu(3x,n,n tk_menuSetFocus)
              deactivate, except in(1,8) the special case  where  the  mouse  moves
              from a menu(3x,n,n tk_menuSetFocus) to a cascaded submenu.

       [3]    When a button is released over a menu(3x,n,n tk_menuSetFocus), the active entry (if(3,n) any)
              is invoked.  The menu(3x,n,n tk_menuSetFocus) also unposts unless it is a torn-off menu.

       [4]    The Space and Return keys invoke the active entry and unpost the
              menu.

       [5]    If any of the entries in(1,8) a menu(3x,n,n tk_menuSetFocus)  have  letters  underlined  with
              with -underline option, then pressing one of the underlined let-
              ters (or its upper-case or lower-case equivalent)  invokes  that
              entry and unposts the menu.

       [6]    The  Escape  key  aborts  a  menu(3x,n,n tk_menuSetFocus)  selection in(1,8) progress without
              invoking any entry.  It also unposts the menu(3x,n,n tk_menuSetFocus)  unless  it  is  a
              torn-off menu.

       [7]    The  Up and Down keys activate the next higher or lower entry in(1,8)
              the menu.  When one end of the menu(3x,n,n tk_menuSetFocus) is reached, the active entry
              wraps around to the other end.

       [8]    The Left key moves to the next menu(3x,n,n tk_menuSetFocus) to the left.  If the current
              menu(3x,n,n tk_menuSetFocus) is a cascaded submenu, then the submenu is unposted and the
              current  menu(3x,n,n tk_menuSetFocus) entry becomes the cascade entry in(1,8) the parent.  If
              the current menu(3x,n,n tk_menuSetFocus) is a top-level menu(3x,n,n tk_menuSetFocus) posted from  a  menubutton,
              then  the current menubutton is unposted and the next menubutton
              to the left is posted.  Otherwise the key has  no  effect.   The
              left-right  order of menubuttons is determined by their stacking
              order:  Tk assumes that the lowest menubutton (which by  default
              is the first one created) is on the left.

       [9]    The  Right key moves to the next menu(3x,n,n tk_menuSetFocus) to the right.  If the cur-
              rent entry is a cascade entry, then the submenu  is  posted  and
              the   current menu(3x,n,n tk_menuSetFocus) entry becomes the first entry in(1,8) the submenu.
              Otherwise, if(3,n) the current menu(3x,n,n tk_menuSetFocus) was  posted  from  a  menubutton,
              then  the current menubutton is unposted and the next menubutton
              to the right is posted.

       Disabled menu(3x,n,n tk_menuSetFocus) entries are non-responsive:  they don't activate and they
       ignore mouse button presses and releases.

       Several  of  the  bindings make use of the command tk_menuSetFocus.  It
       saves the current focus and sets the focus to  its  pathName  argument,
       which is a menu(3x,n,n tk_menuSetFocus) widget.

       The behavior of menus can be changed by defining new bindings for indi-
       vidual widgets or by redefining the class bindings.


BUGS
       At present it isn't possible to use the option database to specify val-
       ues for the options to individual entries.


KEYWORDS
       menu(3x,n,n tk_menuSetFocus), widget



Tk                                    4.1                              menu(3x,n,n tk_menuSetFocus)(n)

References for this manual (incoming links)