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  is  not  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  is not specified, the
57       menubutton's desired width is computed from the size of  the  image  or
58       bitmap or text being displayed in it.
59_________________________________________________________________
60

INTRODUCTION

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

WIDGET COMMAND

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

DEFAULT BINDINGS

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

SEE ALSO

170       ttk::menubutton(n), menu(n)
171

KEYWORDS

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