1menubutton(n)                Tk Built-In Commands                menubutton(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       menubutton - Create and manipulate menubutton widgets
9

SYNOPSIS

11       menubutton pathName ?options?
12

STANDARD OPTIONS

14       -activebackground     -disabledforeground  -padx
15       -activeforeground     -font                -pady
16       -anchor               -foreground          -relief
17       -background           -highlightbackground -takefocus
18       -bitmap               -highlightcolor      -text
19       -borderwidth          -highlightthickness  -textvariable
20       -cursor               -image               -underline
21       -compound             -justify             -wraplength
22
23       See the options manual entry for details on the standard options.
24

WIDGET-SPECIFIC OPTIONS

26       [-direction direction]  Specifies  where  the menu is going to be popup
27       up. above tries to pop the menu above the menubutton.  below  tries  to
28       pop  the  menu  below the menubutton. left tries to pop the menu to the
29       left of the menubutton. right tries to pop the menu to the right of the
30       menu  button. flush pops the menu directly over the menubutton.  In the
31       case of above or below, the direction will  be  reversed  if  the  menu
32       would  show offscreen.  [-height height] Specifies a desired height for
33       the menubutton.  If an image  or  bitmap  is  being  displayed  in  the
34       menubutton  then  the  value  is in screen units (i.e. any of the forms
35       acceptable to Tk_GetPixels); for text it is in lines of text.  If  this
36       option  isn't  specified,  the  menubutton's desired height is computed
37       from the size of the image or bitmap or text  being  displayed  in  it.
38       [-indicatoron indicatorOn]  The  value  must be a proper boolean value.
39       If it is true then a small indicator rectangle will be displayed on the
40       right  side  of the menubutton and the default menu bindings will treat
41       this as an option menubutton.  If false then no indicator will be  dis‐
42       played.   [-menu menu]  Specifies  the path name of the menu associated
43       with this menubutton.  The menu must be  a  child  of  the  menubutton.
44       [-state state]  Specifies one of three states for the menubutton:  nor‐
45       mal, active, or disabled.  In normal state the menubutton is  displayed
46       using the foreground and background options.  The active state is typi‐
47       cally used when the pointer is over the menubutton.   In  active  state
48       the  menubutton is displayed using the activeForeground and activeBack‐
49       ground options.  Disabled state means that  the  menubutton  should  be
50       insensitive:   the  default bindings will refuse to activate the widget
51       and will ignore mouse button presses.  In this state the  disabledFore‐
52       ground  and  background  options determine how the button is displayed.
53       [-width width] Specifies a desired width for  the  menubutton.   If  an
54       image  or bitmap is being displayed in the menubutton then the value is
55       in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for
56       text it is in characters.  If this option isn't specified, the menubut‐
57       ton's desired width is computed from the size of the image or bitmap or
58       text being displayed in it.
59_________________________________________________________________
60
61

INTRODUCTION

63       The  menubutton  command  creates  a  new window (given by the pathName
64       argument) and makes it into a menubutton widget.   Additional  options,
65       described  above, may be specified on the command line or in the option
66       database to configure aspects of the menubutton  such  as  its  colors,
67       font,  text,  and  initial  relief.  The menubutton command returns its
68       pathName argument.  At the time this command is invoked, there must not
69       exist a window named pathName, but pathName's parent must exist.
70
71       A  menubutton  is  a  widget that displays a textual string, bitmap, or
72       image and is associated with a menu widget.  If text is  displayed,  it
73       must  all  be in a single font, but it can occupy multiple lines on the
74       screen (if it contains newlines or if wrapping occurs  because  of  the
75       wrapLength  option)  and one of the characters may optionally be under‐
76       lined using the underline option.  In normal usage, pressing mouse but‐
77       ton  1 over the menubutton causes the associated menu to be posted just
78       underneath the menubutton.  If the mouse is moved over the menu  before
79       releasing  the  mouse  button, the button release causes the underlying
80       menu entry to be invoked.  When the button is  released,  the  menu  is
81       unposted.
82
83       Menubuttons  are  typically organized into groups called menu bars that
84       allow scanning: if the mouse button  is  pressed  over  one  menubutton
85       (causing  it  to  post  its  menu)  and the mouse is moved over another
86       menubutton in the same menu bar without  releasing  the  mouse  button,
87       then  the  menu of the first menubutton is unposted and the menu of the
88       new menubutton is posted instead.
89
90       There are several interactions between menubuttons and menus;  see  the
91       menu  manual entry for information on various menu configurations, such
92       as pulldown menus and option menus.
93
94

WIDGET COMMAND

96       The menubutton command creates a new Tcl command whose  name  is  path‐
97       Name.   This  command  may  be used to invoke various operations on the
98       widget.  It has the following general form:
99              pathName option ?arg arg ...?
100       Option and the args determine the exact behavior of the  command.   The
101       following commands are possible for menubutton widgets:
102
103       pathName cget option
104              Returns  the  current value of the configuration option given by
105              option.  Option may have any  of  the  values  accepted  by  the
106              menubutton command.
107
108       pathName configure ?option? ?value option value ...?
109              Query  or modify the configuration options of the widget.  If no
110              option is specified, returns a list describing all of the avail‐
111              able  options for pathName (see Tk_ConfigureInfo for information
112              on the format of this list).  If option  is  specified  with  no
113              value,  then the command returns a list describing the one named
114              option (this list will be identical to the corresponding sublist
115              of  the  value  returned  if no option is specified).  If one or
116              more option-value pairs are specified, then the command modifies
117              the  given widget option(s) to have the given value(s);  in this
118              case the command returns an empty string.  Option may  have  any
119              of the values accepted by the menubutton command.
120
121

DEFAULT BINDINGS

123       Tk  automatically creates class bindings for menubuttons that give them
124       the following default behavior:
125
126       [1]    A menubutton activates whenever the mouse  passes  over  it  and
127              deactivates whenever the mouse leaves it.
128
129       [2]    Pressing  mouse button 1 over a menubutton posts the menubutton:
130              its relief changes to raised and its associated menu  is  posted
131              under  the  menubutton.   If  the mouse is dragged down into the
132              menu with the button still down, and if the mouse button is then
133              released  over  an entry in the menu, the menubutton is unposted
134              and the menu entry is invoked.
135
136       [3]    If button 1 is pressed over a menubutton and then released  over
137              that menubutton, the menubutton stays posted: you can still move
138              the mouse over the menu and click button 1 on an entry to invoke
139              it.   Once a menu entry has been invoked, the menubutton unposts
140              itself.
141
142       [4]    If button 1 is pressed over a menubutton and then  dragged  over
143              some  other  menubutton,  the original menubutton unposts itself
144              and the new menubutton posts.
145
146       [5]    If button 1 is pressed over a menubutton  and  released  outside
147              any  menubutton or menu, the menubutton unposts without invoking
148              any menu entry.
149
150       [6]    When a menubutton is posted,  its  associated  menu  claims  the
151              input focus to allow keyboard traversal of the menu and its sub‐
152              menus.  See the menu manual entry for details on these bindings.
153
154       [7]    If the underline option has been specified for a menubutton then
155              keyboard  traversal  may  be used to post the menubutton: Alt+x,
156              where x is the underlined character (or its lower-case or upper-
157              case  equivalent), may be typed in any window under the menubut‐
158              ton's toplevel to post the menubutton.
159
160       [8]    The F10 key may be  typed  in  any  window  to  post  the  first
161              menubutton under its toplevel window that isn't disabled.
162
163       [9]    If  a  menubutton has the input focus, the space and return keys
164              post the menubutton.
165
166       If the menubutton's state is disabled then none of  the  above  actions
167       occur:  the menubutton is completely non-responsive.
168
169       The behavior of menubuttons can be changed by defining new bindings for
170       individual widgets or by redefining the class bindings.
171
172

KEYWORDS

174       menubutton, widget
175
176
177
178Tk                                    4.0                        menubutton(n)
Impressum