Debian Codegraph @

pod/Button.pod

raw
1 # Copyright (c) 1990-1994 The Regents of the University of California.
2 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
3 # See the file "license.terms" for information on usage and redistribution
4 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
5 #
6 #
7
8 =head1 NAME
9
10 Tk::Button - Create and manipulate Button widgets
11
12 =for category Tk Widget Classes
13
14 =head1 SYNOPSIS
15
16 I<$button> = I<$parent>-E<gt>B<Button>(?I<options>?);
17
18 =head1 STANDARD OPTIONS
19
20 B<-activebackground>
21 B<-activeforeground>
22 B<-anchor>
23 B<-background>
24 B<-bitmap>
25 B<-borderwidth>
26 B<-compound>
27 B<-cursor>
28 B<-disabledforeground>
29 B<-font>
30 B<-foreground>
31 B<-highlightbackground>
32 B<-highlightcolor>
33 B<-highlightthickness>
34 B<-image>
35 B<-justify>
36 B<-padx>
37 B<-pady>
38 B<-relief>
39 B<-repeatdelay>
40 B<-repeatinterval>
41 B<-takefocus>
42 B<-text>
43 B<-textvariable>
44 B<-underline>
45 B<-wraplength>
46
47 See L<Tk::options> for details of the standard options.
48
49 =head1 WIDGET-SPECIFIC OPTIONS
50
51 =over 4
52
53 =item Name: B<command>
54
55 =item Class: B<Command>
56
57 =item Switch: B<-command>
58
59 Specifies a L<PerlE<sol>Tk callback|Tk::callbacks> to associate with the
60 button. This command is typically invoked when mouse button 1 is
61 released over the button window.
62
63 =item Command-Line Name: B<-compound>
64
65 =item Database Name: B<compound>
66
67 =item Database Class: B<Compound>
68
69 Specifies whether the button should display both an image and text,
70 and if so, where the image should be placed relative to the text.
71 Valid values for this option are B<bottom>, B<center>, B<left>,
72 B<none>, B<right> and B<top>. The default value is B<none>, meaning
73 that the button will display either an image or text, depending on the
74 values of the -image and -bitmap options.
75
76 =item Name: B<default>
77
78 =item Class: B<Default>
79
80 =item Switch: B<-default>
81
82 Specifies one of three states for the default ring: B<normal>,
83 B<active>, or B<disabled>. In active state, the button is drawn
84 with the platform specific appearance for a default button. In normal
85 state, the button is drawn with the platform specific appearance for a
86 non-default button, leaving enough space to draw the default button
87 appearance. The normal and active states will result in buttons of
88 the same size. In disabled state, the button is drawn with the
89 non-default button appearance without leaving space for the default
90 appearance. The disabled state may result in a smaller button than
91 the active state.
92 ring.
93
94 =item Name: B<height>
95
96 =item Class: B<Height>
97
98 =item Switch: B<-height>
99
100 Specifies a desired height for the button.
101 If an image or bitmap is being displayed in the button then the value is in
102 screen units (i.e. any of the forms acceptable to B<Tk_GetPixels>);
103 for text it is in lines of text.
104 If this option isn't specified, the button's desired height is computed
105 from the size of the image or bitmap or text being displayed in it.
106
107 =item Command-Line Name: B<-overrelief>
108
109 =item Database Name: B<overRelief>
110
111 =item Database Class: B<OverRelief>
112
113 Specifies an alternative relief for the button, to be used when
114 the mouse cursor is over the widget. This option can be used to
115 make toolbar buttons, by configuring B<-relief flat -overrelief
116 raised>. If the value of this option is the empty string, then
117 no alternative relief is used when the mouse cursor is over the
118 button. The empty string is the default value.
119
120 =item Name: B<state>
121
122 =item Class: B<State>
123
124 =item Switch: B<-state>
125
126 Specifies one of three states for the button: B<normal>, B<active>,
127 or B<disabled>. In normal state the button is displayed using the
128 B<foreground> and B<background> options. The active state is
129 typically used when the pointer is over the button. In active state
130 the button is displayed using the B<activeForeground> and
131 B<activeBackground> options. Disabled state means that the button
132 should be insensitive: the default bindings will refuse to activate
133 the widget and will ignore mouse button presses.
134 In this state the B<disabledForeground> and
135 B<background> options determine how the button is displayed.
136
137 =item Name: B<width>
138
139 =item Class: B<Width>
140
141 =item Switch: B<-width>
142
143 Specifies a desired width for the button.
144 If an image or bitmap is being displayed in the button then the value is in
145 screen units (i.e. any of the forms acceptable to B<Tk_GetPixels>);
146 for text it is in characters.
147 If this option isn't specified, the button's desired width is computed
148 from the size of the image or bitmap or text being displayed in it.
149
150 =back
151
152 =head1 DESCRIPTION
153
154 The B<Button> method creates a new window (given by the
155 $widget argument) and makes it into a button widget.
156 Additional
157 options, described above, may be specified on the command line
158 or in the option database
159 to configure aspects of the button such as its colors, font,
160 text, and initial relief. The B<button> command returns its
161 $widget argument. At the time this command is invoked,
162 there must not exist a window named $widget, but
163 $widget's parent must exist.
164
165 A button is a widget that displays a textual string, bitmap or image.
166 If text is displayed, it must all be in a single font, but it
167 can occupy multiple lines on the screen (if it contains newlines
168 or if wrapping occurs because of the B<-wraplength> option) and
169 one of the characters may optionally be underlined using the
170 B<-underline> option.
171 It can display itself in either of three different ways, according
172 to
173 the B<-state> option;
174 it can be made to appear raised, sunken, or flat;
175 and it can be made to flash. When a user invokes the
176 button (by pressing mouse button 1 with the cursor over the
177 button), then the L<perlE<sol>Tk callback|Tk::callbacks> specified in the B<-command>
178 option is invoked.
179
180 =head1 WIDGET METHODS
181
182 The B<Button> method creates a widget object.
183 This object supports the B<configure> and B<cget> methods
184 described in L<Tk::options> which can be used to enquire and
185 modify the options described above.
186 The widget also inherits all the methods provided by the generic
187 L<Tk::Widget|Tk::Widget> class.
188
189 The following additional methods are available for button widgets:
190
191 =over 4
192
193 =item I<$button>-E<gt>B<flash>
194
195 Flash the button. This is accomplished by redisplaying the button
196 several times, alternating between active and normal colors. At
197 the end of the flash the button is left in the same normal/active
198 state as when the command was invoked.
199 This command is ignored if the button's state is B<disabled>.
200
201 =item I<$button>-E<gt>B<invoke>
202
203 Invoke the L<callback|Tk::callbacks> associated with the buttons
204 B<-command> option, if there is one.
205 The return value is the return value from the callback, or the
206 undefined value if there is no callback associated with the button.
207 This command is ignored if the button's state is B<disabled>.
208
209 =back
210
211 =head1 DEFAULT BINDINGS
212
213 Tk automatically creates class bindings for buttons that give them
214 default behavior:
215
216 =over 4
217
218 =item [1]
219
220 A button activates whenever the mouse passes over it and deactivates
221 whenever the mouse leaves the button.
222 Under Windows, this binding is only active when mouse button 1 has
223 been pressed over the button.
224
225 =item [2]
226
227 A button's relief is changed to sunken whenever mouse button 1 is
228 pressed over the button, and the relief is restored to its original
229 value when button 1 is later released.
230
231 =item [3]
232
233 If mouse button 1 is pressed over a button and later released over
234 the button, the button is invoked. However, if the mouse is not
235 over the button when button 1 is released, then no invocation occurs.
236
237 =item [4]
238
239 When a button has the input focus, the space key causes the button
240 to be invoked.
241
242 If the button's state is B<disabled> then none of the above
243 actions occur: the button is completely non-responsive.
244
245 The behavior of buttons can be changed by defining new bindings for
246 individual widgets or by redefining the class bindings.
247
248 =back
249
250 =head1 KEYWORDS
251
252 button, widget
253
254 =cut
255