Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | '\" |
2 | '\" Copyright (c) 2000 Jeffrey Hobbs. | |
3 | '\" Copyright (c) 2000 Ajuba Solutions. | |
4 | '\" | |
5 | '\" See the file "license.terms" for information on usage and redistribution | |
6 | '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
7 | '\" | |
8 | '\" RCS: @(#) $Id: spinbox.n,v 1.3.2.1 2004/10/28 12:25:22 dkf Exp $ | |
9 | '\" | |
10 | '\" The definitions below are for supplemental macros used in Tcl/Tk | |
11 | '\" manual entries. | |
12 | '\" | |
13 | '\" .AP type name in/out ?indent? | |
14 | '\" Start paragraph describing an argument to a library procedure. | |
15 | '\" type is type of argument (int, etc.), in/out is either "in", "out", | |
16 | '\" or "in/out" to describe whether procedure reads or modifies arg, | |
17 | '\" and indent is equivalent to second arg of .IP (shouldn't ever be | |
18 | '\" needed; use .AS below instead) | |
19 | '\" | |
20 | '\" .AS ?type? ?name? | |
21 | '\" Give maximum sizes of arguments for setting tab stops. Type and | |
22 | '\" name are examples of largest possible arguments that will be passed | |
23 | '\" to .AP later. If args are omitted, default tab stops are used. | |
24 | '\" | |
25 | '\" .BS | |
26 | '\" Start box enclosure. From here until next .BE, everything will be | |
27 | '\" enclosed in one large box. | |
28 | '\" | |
29 | '\" .BE | |
30 | '\" End of box enclosure. | |
31 | '\" | |
32 | '\" .CS | |
33 | '\" Begin code excerpt. | |
34 | '\" | |
35 | '\" .CE | |
36 | '\" End code excerpt. | |
37 | '\" | |
38 | '\" .VS ?version? ?br? | |
39 | '\" Begin vertical sidebar, for use in marking newly-changed parts | |
40 | '\" of man pages. The first argument is ignored and used for recording | |
41 | '\" the version when the .VS was added, so that the sidebars can be | |
42 | '\" found and removed when they reach a certain age. If another argument | |
43 | '\" is present, then a line break is forced before starting the sidebar. | |
44 | '\" | |
45 | '\" .VE | |
46 | '\" End of vertical sidebar. | |
47 | '\" | |
48 | '\" .DS | |
49 | '\" Begin an indented unfilled display. | |
50 | '\" | |
51 | '\" .DE | |
52 | '\" End of indented unfilled display. | |
53 | '\" | |
54 | '\" .SO | |
55 | '\" Start of list of standard options for a Tk widget. The | |
56 | '\" options follow on successive lines, in four columns separated | |
57 | '\" by tabs. | |
58 | '\" | |
59 | '\" .SE | |
60 | '\" End of list of standard options for a Tk widget. | |
61 | '\" | |
62 | '\" .OP cmdName dbName dbClass | |
63 | '\" Start of description of a specific option. cmdName gives the | |
64 | '\" option's name as specified in the class command, dbName gives | |
65 | '\" the option's name in the option database, and dbClass gives | |
66 | '\" the option's class in the option database. | |
67 | '\" | |
68 | '\" .UL arg1 arg2 | |
69 | '\" Print arg1 underlined, then print arg2 normally. | |
70 | '\" | |
71 | '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $ | |
72 | '\" | |
73 | '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages. | |
74 | .if t .wh -1.3i ^B | |
75 | .nr ^l \n(.l | |
76 | .ad b | |
77 | '\" # Start an argument description | |
78 | .de AP | |
79 | .ie !"\\$4"" .TP \\$4 | |
80 | .el \{\ | |
81 | . ie !"\\$2"" .TP \\n()Cu | |
82 | . el .TP 15 | |
83 | .\} | |
84 | .ta \\n()Au \\n()Bu | |
85 | .ie !"\\$3"" \{\ | |
86 | \&\\$1 \\fI\\$2\\fP (\\$3) | |
87 | .\".b | |
88 | .\} | |
89 | .el \{\ | |
90 | .br | |
91 | .ie !"\\$2"" \{\ | |
92 | \&\\$1 \\fI\\$2\\fP | |
93 | .\} | |
94 | .el \{\ | |
95 | \&\\fI\\$1\\fP | |
96 | .\} | |
97 | .\} | |
98 | .. | |
99 | '\" # define tabbing values for .AP | |
100 | .de AS | |
101 | .nr )A 10n | |
102 | .if !"\\$1"" .nr )A \\w'\\$1'u+3n | |
103 | .nr )B \\n()Au+15n | |
104 | .\" | |
105 | .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n | |
106 | .nr )C \\n()Bu+\\w'(in/out)'u+2n | |
107 | .. | |
108 | .AS Tcl_Interp Tcl_CreateInterp in/out | |
109 | '\" # BS - start boxed text | |
110 | '\" # ^y = starting y location | |
111 | '\" # ^b = 1 | |
112 | .de BS | |
113 | .br | |
114 | .mk ^y | |
115 | .nr ^b 1u | |
116 | .if n .nf | |
117 | .if n .ti 0 | |
118 | .if n \l'\\n(.lu\(ul' | |
119 | .if n .fi | |
120 | .. | |
121 | '\" # BE - end boxed text (draw box now) | |
122 | .de BE | |
123 | .nf | |
124 | .ti 0 | |
125 | .mk ^t | |
126 | .ie n \l'\\n(^lu\(ul' | |
127 | .el \{\ | |
128 | .\" Draw four-sided box normally, but don't draw top of | |
129 | .\" box if the box started on an earlier page. | |
130 | .ie !\\n(^b-1 \{\ | |
131 | \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
132 | .\} | |
133 | .el \}\ | |
134 | \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul' | |
135 | .\} | |
136 | .\} | |
137 | .fi | |
138 | .br | |
139 | .nr ^b 0 | |
140 | .. | |
141 | '\" # VS - start vertical sidebar | |
142 | '\" # ^Y = starting y location | |
143 | '\" # ^v = 1 (for troff; for nroff this doesn't matter) | |
144 | .de VS | |
145 | .if !"\\$2"" .br | |
146 | .mk ^Y | |
147 | .ie n 'mc \s12\(br\s0 | |
148 | .el .nr ^v 1u | |
149 | .. | |
150 | '\" # VE - end of vertical sidebar | |
151 | .de VE | |
152 | .ie n 'mc | |
153 | .el \{\ | |
154 | .ev 2 | |
155 | .nf | |
156 | .ti 0 | |
157 | .mk ^t | |
158 | \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n' | |
159 | .sp -1 | |
160 | .fi | |
161 | .ev | |
162 | .\} | |
163 | .nr ^v 0 | |
164 | .. | |
165 | '\" # Special macro to handle page bottom: finish off current | |
166 | '\" # box/sidebar if in box/sidebar mode, then invoked standard | |
167 | '\" # page bottom macro. | |
168 | .de ^B | |
169 | .ev 2 | |
170 | 'ti 0 | |
171 | 'nf | |
172 | .mk ^t | |
173 | .if \\n(^b \{\ | |
174 | .\" Draw three-sided box if this is the box's first page, | |
175 | .\" draw two sides but no top otherwise. | |
176 | .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
177 | .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c | |
178 | .\} | |
179 | .if \\n(^v \{\ | |
180 | .nr ^x \\n(^tu+1v-\\n(^Yu | |
181 | \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c | |
182 | .\} | |
183 | .bp | |
184 | 'fi | |
185 | .ev | |
186 | .if \\n(^b \{\ | |
187 | .mk ^y | |
188 | .nr ^b 2 | |
189 | .\} | |
190 | .if \\n(^v \{\ | |
191 | .mk ^Y | |
192 | .\} | |
193 | .. | |
194 | '\" # DS - begin display | |
195 | .de DS | |
196 | .RS | |
197 | .nf | |
198 | .sp | |
199 | .. | |
200 | '\" # DE - end display | |
201 | .de DE | |
202 | .fi | |
203 | .RE | |
204 | .sp | |
205 | .. | |
206 | '\" # SO - start of list of standard options | |
207 | .de SO | |
208 | .SH "STANDARD OPTIONS" | |
209 | .LP | |
210 | .nf | |
211 | .ta 5.5c 11c | |
212 | .ft B | |
213 | .. | |
214 | '\" # SE - end of list of standard options | |
215 | .de SE | |
216 | .fi | |
217 | .ft R | |
218 | .LP | |
219 | See the \\fBoptions\\fR manual entry for details on the standard options. | |
220 | .. | |
221 | '\" # OP - start of full description for a single option | |
222 | .de OP | |
223 | .LP | |
224 | .nf | |
225 | .ta 4c | |
226 | Command-Line Name: \\fB\\$1\\fR | |
227 | Database Name: \\fB\\$2\\fR | |
228 | Database Class: \\fB\\$3\\fR | |
229 | .fi | |
230 | .IP | |
231 | .. | |
232 | '\" # CS - begin code excerpt | |
233 | .de CS | |
234 | .RS | |
235 | .nf | |
236 | .ta .25i .5i .75i 1i | |
237 | .. | |
238 | '\" # CE - end code excerpt | |
239 | .de CE | |
240 | .fi | |
241 | .RE | |
242 | .. | |
243 | .de UL | |
244 | \\$1\l'|0\(ul'\\$2 | |
245 | .. | |
246 | .TH spinbox n 8.4 Tk "Tk Built-In Commands" | |
247 | .BS | |
248 | '\" Note: do not modify the .SH NAME line immediately below! | |
249 | .SH NAME | |
250 | spinbox \- Create and manipulate spinbox widgets | |
251 | .SH SYNOPSIS | |
252 | \fBspinbox\fR \fIpathName \fR?\fIoptions\fR? | |
253 | .SO | |
254 | \-activebackground \-highlightthickness \-repeatinterval | |
255 | \-background \-insertbackground \-selectbackground | |
256 | \-borderwidth \-insertborderwidth \-selectborderwidth | |
257 | \-cursor \-insertontime \-selectforeground | |
258 | \-exportselection \-insertwidth \-takefocus | |
259 | \-font \-insertofftime \-textvariable | |
260 | \-foreground \-justify \-xscrollcommand | |
261 | \-highlightbackground \-relief | |
262 | \-highlightcolor \-repeatdelay | |
263 | .SE | |
264 | .SH "WIDGET-SPECIFIC OPTIONS" | |
265 | .OP \-buttonbackground buttonBackground Background | |
266 | The background color to be used for the spin buttons. | |
267 | .OP \-buttoncursor buttonCursor Cursor | |
268 | The cursor to be used when over the spin buttons. If this is empty | |
269 | (the default), a default cursor will be used. | |
270 | .OP \-buttondownrelief buttonDownRelief Relief | |
271 | The relief to be used for the upper spin button. | |
272 | .OP \-buttonuprelief buttonUpRelief Relief | |
273 | The relief to be used for the lower spin button. | |
274 | .OP \-command command Command | |
275 | Specifies a Tcl command to invoke whenever a spinbutton is invoked. | |
276 | The command recognizes several percent substitutions: \fB%W\fR for | |
277 | the widget path, \fB%s\fR for the current value of the widget, and | |
278 | \fB%d\fR for the direction of the button pressed (\fBup\fR or \fBdown\fR). | |
279 | .OP \-disabledbackground disabledBackground DisabledBackground | |
280 | Specifies the background color to use when the spinbox is disabled. If | |
281 | this option is the empty string, the normal background color is used. | |
282 | .OP \-disabledforeground disabledForeground DisabledForeground | |
283 | Specifies the foreground color to use when the spinbox is disabled. If | |
284 | this option is the empty string, the normal foreground color is used. | |
285 | .OP \-format format Format | |
286 | Specifies an alternate format to use when setting the string value | |
287 | when using the \fB\-from\fR and \fB\-to\fR range. | |
288 | This must be a format specifier of the form \fB%<pad>.<pad>f\fR, | |
289 | as it will format a floating-point number. | |
290 | .OP \-from from From | |
291 | A floating-point value corresponding to the lowest value for a spinbox, to | |
292 | be used in conjunction with \fB\-to\fR and \fB\-increment\fR. When all | |
293 | are specified correctly, the spinbox will use these values to control its | |
294 | contents. This value must be less than the \fB\-to\fR option. | |
295 | If \fB\-values\fR is specified, it supercedes this option. | |
296 | .OP "\-invalidcommand or \-invcmd" invalidCommand InvalidCommand | |
297 | Specifies a script to eval when \fBvalidateCommand\fR returns 0. Setting | |
298 | it to an empty string disables this feature (the default). The best use of | |
299 | this option is to set it to \fIbell\fR. See \fBValidation\fR below for | |
300 | more information. | |
301 | .OP \-increment increment Increment | |
302 | A floating-point value specifying the increment. When used with | |
303 | \fB\-from\fR and \fB\-to\fR, the value in the widget will be adjusted by | |
304 | \fB\-increment\fR when a spin button is pressed (up adds the value, | |
305 | down subtracts the value). | |
306 | .OP \-readonlybackground readonlyBackground ReadonlyBackground | |
307 | Specifies the background color to use when the spinbox is readonly. If | |
308 | this option is the empty string, the normal background color is used. | |
309 | .OP \-state state State | |
310 | Specifies one of three states for the spinbox: \fBnormal\fR, | |
311 | \fBdisabled\fR, or \fBreadonly\fR. If the spinbox is readonly, then the | |
312 | value may not be changed using widget commands and no insertion cursor | |
313 | will be displayed, even if the input focus is in the widget; the | |
314 | contents of the widget may still be selected. If the spinbox is | |
315 | disabled, the value may not be changed, no insertion cursor will be | |
316 | displayed, the contents will not be selectable, and the spinbox may | |
317 | be displayed in a different color, depending on the values of the | |
318 | \fB-disabledforeground\fR and \fB-disabledbackground\fR options. | |
319 | .OP \-to to To | |
320 | A floating-point value corresponding to the highest value for the spinbox, | |
321 | to be used in conjunction with \fB\-from\fR and \fB\-increment\fR. When | |
322 | all are specified correctly, the spinbox will use these values to control | |
323 | its contents. This value must be greater than the \fB\-from\fR option. | |
324 | If \fB\-values\fR is specified, it supercedes this option. | |
325 | .OP \-validate validate Validate | |
326 | Specifies the mode in which validation should operate: \fBnone\fR, | |
327 | \fBfocus\fR, \fBfocusin\fR, \fBfocusout\fR, \fBkey\fR, or \fBall\fR. | |
328 | It defaults to \fBnone\fR. When you want validation, you must explicitly | |
329 | state which mode you wish to use. See \fBValidation\fR below for more. | |
330 | .OP "\-validatecommand or \-vcmd" validateCommand ValidateCommand | |
331 | Specifies a script to evaluate when you want to validate the input in the | |
332 | widget. Setting it to an empty string disables this feature (the default). | |
333 | Validation occurs according to the value of \fB\-validate\fR. | |
334 | This command must return a valid Tcl boolean value. If it returns 0 (or | |
335 | the valid Tcl boolean equivalent) then the value of the widget will not | |
336 | change and the \fBinvalidCommand\fR will be evaluated if it is set. If it | |
337 | returns 1, then value will be changed. | |
338 | See \fBValidation\fR below for more information. | |
339 | .OP \-values values Values | |
340 | Must be a proper list value. If specified, the spinbox will use these | |
341 | values as to control its contents, starting with the first value. This | |
342 | option has precedence over the \fB\-from\fR and \fB\-to\fR range. | |
343 | .OP \-width width Width | |
344 | Specifies an integer value indicating the desired width of the spinbox window, | |
345 | in average-size characters of the widget's font. | |
346 | If the value is less than or equal to zero, the widget picks a | |
347 | size just large enough to hold its current text. | |
348 | .OP \-wrap wrap wrap | |
349 | Must be a proper boolean value. If on, the spinbox will wrap around the | |
350 | values of data in the widget. | |
351 | .BE | |
352 | ||
353 | .SH DESCRIPTION | |
354 | .PP | |
355 | The \fBspinbox\fR command creates a new window (given by the | |
356 | \fIpathName\fR argument) and makes it into a spinbox widget. | |
357 | Additional options, described above, may be specified on the | |
358 | command line or in the option database | |
359 | to configure aspects of the spinbox such as its colors, font, | |
360 | and relief. The \fBspinbox\fR command returns its | |
361 | \fIpathName\fR argument. At the time this command is invoked, | |
362 | there must not exist a window named \fIpathName\fR, but | |
363 | \fIpathName\fR's parent must exist. | |
364 | .PP | |
365 | A \fBspinbox\fR is an extended \fBentry\fR widget that allows he user | |
366 | to move, or spin, through a fixed set of ascending or descending values | |
367 | such as times or dates in addition to editing the value as in an | |
368 | \fBentry\fR. When first created, a spinbox's string is empty. | |
369 | A portion of the spinbox may be selected as described below. | |
370 | If a spinbox is exporting its selection (see the \fBexportSelection\fR | |
371 | option), then it will observe the standard protocols for handling the | |
372 | selection; spinbox selections are available as type \fBSTRING\fR. | |
373 | Spinboxes also observe the standard Tk rules for dealing with the | |
374 | input focus. When a spinbox has the input focus it displays an | |
375 | \fIinsertion cursor\fR to indicate where new characters will be | |
376 | inserted. | |
377 | .PP | |
378 | Spinboxes are capable of displaying strings that are too long to | |
379 | fit entirely within the widget's window. In this case, only a | |
380 | portion of the string will be displayed; commands described below | |
381 | may be used to change the view in the window. Spinboxes use | |
382 | the standard \fBxScrollCommand\fR mechanism for interacting with | |
383 | scrollbars (see the description of the \fBxScrollCommand\fR option | |
384 | for details). They also support scanning, as described below. | |
385 | ||
386 | .SH VALIDATION | |
387 | .PP | |
388 | Validation works by setting the \fBvalidateCommand\fR | |
389 | option to a script which will be evaluated according to the \fBvalidate\fR | |
390 | option as follows: | |
391 | .PP | |
392 | .IP \fBnone\fR 10 | |
393 | Default. This means no validation will occur. | |
394 | .IP \fBfocus\fR 10 | |
395 | \fBvalidateCommand\fR will be called when the spinbox receives or | |
396 | loses focus. | |
397 | .IP \fBfocusin\fR 10 | |
398 | \fBvalidateCommand\fR will be called when the spinbox receives focus. | |
399 | .IP \fBfocusout\fR 10 | |
400 | \fBvalidateCommand\fR will be called when the spinbox loses focus. | |
401 | .IP \fBkey\fR 10 | |
402 | \fBvalidateCommand\fR will be called when the spinbox is edited. | |
403 | .IP \fBall\fR 10 | |
404 | \fBvalidateCommand\fR will be called for all above conditions. | |
405 | .PP | |
406 | It is possible to perform percent substitutions on the \fBvalidateCommand\fR | |
407 | and \fBinvalidCommand\fR, just as you would in a \fBbind\fR script. The | |
408 | following substitutions are recognized: | |
409 | .PP | |
410 | .IP \fB%d\fR 5 | |
411 | Type of action: 1 for \fBinsert\fR, 0 for \fBdelete\fR, | |
412 | or -1 for focus, forced or textvariable validation. | |
413 | .IP \fB%i\fR 5 | |
414 | Index of char string to be inserted/deleted, if any, otherwise -1. | |
415 | .IP \fB%P\fR 5 | |
416 | The value of the spinbox should edition occur. If you are configuring the | |
417 | spinbox widget to have a new textvariable, this will be the value of that | |
418 | textvariable. | |
419 | .IP \fB%s\fR 5 | |
420 | The current value of spinbox before edition. | |
421 | .IP \fB%S\fR 5 | |
422 | The text string being inserted/deleted, if any. | |
423 | Otherwise it is an empty string. | |
424 | .IP \fB%v\fR 5 | |
425 | The type of validation currently set. | |
426 | .IP \fB%V\fR 5 | |
427 | The type of validation that triggered the callback | |
428 | (key, focusin, focusout, forced). | |
429 | .IP \fB%W\fR 5 | |
430 | The name of the spinbox widget. | |
431 | .PP | |
432 | In general, the \fBtextVariable\fR and \fBvalidateCommand\fR can be | |
433 | dangerous to mix. Any problems have been overcome so that using the | |
434 | \fBvalidateCommand\fR will not interfere with the traditional behavior of | |
435 | the spinbox widget. Using the \fBtextVariable\fR for read-only purposes will | |
436 | never cause problems. The danger comes when you try set the | |
437 | \fBtextVariable\fR to something that the \fBvalidateCommand\fR would not | |
438 | accept, which causes \fBvalidate\fR to become \fInone\fR (the | |
439 | \fBinvalidCommand\fR will not be triggered). The same happens | |
440 | when an error occurs evaluating the \fBvalidateCommand\fR. | |
441 | .PP | |
442 | Primarily, an error will occur when the \fBvalidateCommand\fR or | |
443 | \fBinvalidCommand\fR encounters an error in its script while evaluating or | |
444 | \fBvalidateCommand\fR does not return a valid Tcl boolean value. The | |
445 | \fBvalidate\fR option will also set itself to \fBnone\fR when you edit the | |
446 | spinbox widget from within either the \fBvalidateCommand\fR or the | |
447 | \fBinvalidCommand\fR. Such editions will override the one that was being | |
448 | validated. If you wish to edit the value of the widget | |
449 | during validation and still have the \fBvalidate\fR option set, you should | |
450 | include the command | |
451 | .CS | |
452 | \fI%W config -validate %v\fR | |
453 | .CE | |
454 | in the \fBvalidateCommand\fR or \fBinvalidCommand\fR (whichever one you | |
455 | were editing the spinbox widget from). It is also recommended to not set an | |
456 | associated \fBtextVariable\fR during validation, as that can cause the | |
457 | spinbox widget to become out of sync with the \fBtextVariable\fR. | |
458 | ||
459 | .SH "WIDGET COMMAND" | |
460 | .PP | |
461 | The \fBspinbox\fR command creates a new Tcl command whose | |
462 | name is \fIpathName\fR. This command may be used to invoke various | |
463 | operations on the widget. It has the following general form: | |
464 | .CS | |
465 | \fIpathName option \fR?\fIarg arg ...\fR? | |
466 | .CE | |
467 | \fIOption\fR and the \fIarg\fRs | |
468 | determine the exact behavior of the command. | |
469 | .PP | |
470 | Many of the widget commands for spinboxes take one or more indices as | |
471 | arguments. An index specifies a particular character in the spinbox's | |
472 | string, in any of the following ways: | |
473 | .TP 12 | |
474 | \fInumber\fR | |
475 | Specifies the character as a numerical index, where 0 corresponds | |
476 | to the first character in the string. | |
477 | .TP 12 | |
478 | \fBanchor\fR | |
479 | Indicates the anchor point for the selection, which is set with the | |
480 | \fBselect from\fR and \fBselect adjust\fR widget commands. | |
481 | .TP 12 | |
482 | \fBend\fR | |
483 | Indicates the character just after the last one in the spinbox's string. | |
484 | This is equivalent to specifying a numerical index equal to the length | |
485 | of the spinbox's string. | |
486 | .TP 12 | |
487 | \fBinsert\fR | |
488 | Indicates the character adjacent to and immediately following the | |
489 | insertion cursor. | |
490 | .TP 12 | |
491 | \fBsel.first\fR | |
492 | Indicates the first character in the selection. It is an error to | |
493 | use this form if the selection isn't in the spinbox window. | |
494 | .TP 12 | |
495 | \fBsel.last\fR | |
496 | Indicates the character just after the last one in the selection. | |
497 | It is an error to use this form if the selection isn't in the | |
498 | spinbox window. | |
499 | .TP 12 | |
500 | \fB@\fInumber\fR | |
501 | In this form, \fInumber\fR is treated as an x-coordinate in the | |
502 | spinbox's window; the character spanning that x-coordinate is used. | |
503 | For example, ``\fB@0\fR'' indicates the left-most character in the | |
504 | window. | |
505 | .LP | |
506 | Abbreviations may be used for any of the forms above, e.g. ``\fBe\fR'' | |
507 | or ``\fBsel.f\fR''. In general, out-of-range indices are automatically | |
508 | rounded to the nearest legal value. | |
509 | .PP | |
510 | The following commands are possible for spinbox widgets: | |
511 | .TP | |
512 | \fIpathName \fBbbox \fIindex\fR | |
513 | Returns a list of four numbers describing the bounding box of the | |
514 | character given by \fIindex\fR. | |
515 | The first two elements of the list give the x and y coordinates of | |
516 | the upper-left corner of the screen area covered by the character | |
517 | (in pixels relative to the widget) and the last two elements give | |
518 | the width and height of the character, in pixels. | |
519 | The bounding box may refer to a region outside the visible area | |
520 | of the window. | |
521 | .TP | |
522 | \fIpathName \fBcget\fR \fIoption\fR | |
523 | Returns the current value of the configuration option given | |
524 | by \fIoption\fR. | |
525 | \fIOption\fR may have any of the values accepted by the \fBspinbox\fR | |
526 | command. | |
527 | .TP | |
528 | \fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR? | |
529 | Query or modify the configuration options of the widget. | |
530 | If no \fIoption\fR is specified, returns a list describing all of | |
531 | the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for | |
532 | information on the format of this list). If \fIoption\fR is specified | |
533 | with no \fIvalue\fR, then the command returns a list describing the | |
534 | one named option (this list will be identical to the corresponding | |
535 | sublist of the value returned if no \fIoption\fR is specified). If | |
536 | one or more \fIoption\-value\fR pairs are specified, then the command | |
537 | modifies the given widget option(s) to have the given value(s); in | |
538 | this case the command returns an empty string. | |
539 | \fIOption\fR may have any of the values accepted by the \fBspinbox\fR | |
540 | command. | |
541 | .TP | |
542 | \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR? | |
543 | Delete one or more elements of the spinbox. | |
544 | \fIFirst\fR is the index of the first character to delete, and | |
545 | \fIlast\fR is the index of the character just after the last | |
546 | one to delete. | |
547 | If \fIlast\fR isn't specified it defaults to \fIfirst\fR+1, | |
548 | i.e. a single character is deleted. | |
549 | This command returns an empty string. | |
550 | .TP | |
551 | \fIpathName \fBget\fR | |
552 | Returns the spinbox's string. | |
553 | .TP | |
554 | \fIpathName \fBicursor \fIindex\fR | |
555 | Arrange for the insertion cursor to be displayed just before the character | |
556 | given by \fIindex\fR. Returns an empty string. | |
557 | .TP | |
558 | \fIpathName \fBidentify\fI x y\fR | |
559 | Returns the name of the window element corresponding to coordinates | |
560 | \fIx\fR and \fIy\fR in the spinbox. Return value is one of: | |
561 | \fBnone\fR, \fBbuttondown\fR, \fBbuttonup\fR, \fBentry\fR. | |
562 | .TP | |
563 | \fIpathName \fBindex\fI index\fR | |
564 | Returns the numerical index corresponding to \fIindex\fR. | |
565 | .TP | |
566 | \fIpathName \fBinsert \fIindex string\fR | |
567 | Insert the characters of \fIstring\fR just before the character | |
568 | indicated by \fIindex\fR. Returns an empty string. | |
569 | .TP | |
570 | \fIpathName \fBinvoke\fI element\fR | |
571 | Causes the specified element, either \fBbuttondown\fR or \fBbuttonup\fR, | |
572 | to be invoked, triggering the action associated with it. | |
573 | .TP | |
574 | \fIpathName \fBscan\fR \fIoption args\fR | |
575 | This command is used to implement scanning on spinboxes. It has | |
576 | two forms, depending on \fIoption\fR: | |
577 | .RS | |
578 | .TP | |
579 | \fIpathName \fBscan mark \fIx\fR | |
580 | Records \fIx\fR and the current view in the spinbox window; used in | |
581 | conjunction with later \fBscan dragto\fR commands. Typically this | |
582 | command is associated with a mouse button press in the widget. It | |
583 | returns an empty string. | |
584 | .TP | |
585 | \fIpathName \fBscan dragto \fIx\fR | |
586 | This command computes the difference between its \fIx\fR argument | |
587 | and the \fIx\fR argument to the last \fBscan mark\fR command for | |
588 | the widget. It then adjusts the view left or right by 10 times the | |
589 | difference in x-coordinates. This command is typically associated | |
590 | with mouse motion events in the widget, to produce the effect of | |
591 | dragging the spinbox at high speed through the window. The return | |
592 | value is an empty string. | |
593 | .RE | |
594 | .TP | |
595 | \fIpathName \fBselection \fIoption arg\fR | |
596 | This command is used to adjust the selection within a spinbox. It | |
597 | has several forms, depending on \fIoption\fR: | |
598 | .RS | |
599 | .TP | |
600 | \fIpathName \fBselection adjust \fIindex\fR | |
601 | Locate the end of the selection nearest to the character given by | |
602 | \fIindex\fR, and adjust that end of the selection to be at \fIindex\fR | |
603 | (i.e. including but not going beyond \fIindex\fR). The other | |
604 | end of the selection is made the anchor point for future | |
605 | \fBselect to\fR commands. If the selection | |
606 | isn't currently in the spinbox, then a new selection is created to | |
607 | include the characters between \fIindex\fR and the most recent | |
608 | selection anchor point, inclusive. | |
609 | Returns an empty string. | |
610 | .TP | |
611 | \fIpathName \fBselection clear\fR | |
612 | Clear the selection if it is currently in this widget. If the | |
613 | selection isn't in this widget then the command has no effect. | |
614 | Returns an empty string. | |
615 | .TP | |
616 | \fIpathName \fBselection element\fR ?\fIelement\fR? | |
617 | Sets or gets the currently selected element. If a spinbutton element | |
618 | is specified, it will be displayed depressed. | |
619 | .TP | |
620 | \fIpathName \fBselection from \fIindex\fR | |
621 | Set the selection anchor point to just before the character | |
622 | given by \fIindex\fR. Doesn't change the selection. | |
623 | Returns an empty string. | |
624 | .TP | |
625 | \fIpathName \fBselection present\fR | |
626 | Returns 1 if there is are characters selected in the spinbox, | |
627 | 0 if nothing is selected. | |
628 | .TP | |
629 | \fIpathName \fBselection range \fIstart\fR \fIend\fR | |
630 | Sets the selection to include the characters starting with | |
631 | the one indexed by \fIstart\fR and ending with the one just | |
632 | before \fIend\fR. | |
633 | If \fIend\fR refers to the same character as \fIstart\fR or an | |
634 | earlier one, then the spinbox's selection is cleared. | |
635 | .TP | |
636 | \fIpathName \fBselection to \fIindex\fR | |
637 | If \fIindex\fR is before the anchor point, set the selection | |
638 | to the characters from \fIindex\fR up to but not including | |
639 | the anchor point. | |
640 | If \fIindex\fR is the same as the anchor point, do nothing. | |
641 | If \fIindex\fR is after the anchor point, set the selection | |
642 | to the characters from the anchor point up to but not including | |
643 | \fIindex\fR. | |
644 | The anchor point is determined by the most recent \fBselect from\fR | |
645 | or \fBselect adjust\fR command in this widget. | |
646 | If the selection isn't in this widget then a new selection is | |
647 | created using the most recent anchor point specified for the widget. | |
648 | Returns an empty string. | |
649 | .RE | |
650 | .TP | |
651 | \fIpathName \fBset\fR ?\fIstring\fR? | |
652 | If \fIstring\fR is specified, the spinbox will try and set it to this | |
653 | value, otherwise it just returns the spinbox's string. | |
654 | If validation is on, it will occur when setting the string. | |
655 | .TP | |
656 | \fIpathName \fBvalidate\fR | |
657 | This command is used to force an evaluation of the \fBvalidateCommand\fR | |
658 | independent of the conditions specified by the \fBvalidate\fR option. | |
659 | This is done by temporarily setting the \fBvalidate\fR option to \fBall\fR. | |
660 | It returns 0 or 1. | |
661 | .TP | |
662 | \fIpathName \fBxview \fIargs\fR | |
663 | This command is used to query and change the horizontal position of the | |
664 | text in the widget's window. It can take any of the following | |
665 | forms: | |
666 | .RS | |
667 | .TP | |
668 | \fIpathName \fBxview\fR | |
669 | Returns a list containing two elements. | |
670 | Each element is a real fraction between 0 and 1; together they describe | |
671 | the horizontal span that is visible in the window. | |
672 | For example, if the first element is .2 and the second element is .6, | |
673 | 20% of the spinbox's text is off-screen to the left, the middle 40% is visible | |
674 | in the window, and 40% of the text is off-screen to the right. | |
675 | These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR | |
676 | option. | |
677 | .TP | |
678 | \fIpathName \fBxview\fR \fIindex\fR | |
679 | Adjusts the view in the window so that the character given by \fIindex\fR | |
680 | is displayed at the left edge of the window. | |
681 | .TP | |
682 | \fIpathName \fBxview moveto\fI fraction\fR | |
683 | Adjusts the view in the window so that the character \fIfraction\fR of the | |
684 | way through the text appears at the left edge of the window. | |
685 | \fIFraction\fR must be a fraction between 0 and 1. | |
686 | .TP | |
687 | \fIpathName \fBxview scroll \fInumber what\fR | |
688 | This command shifts the view in the window left or right according to | |
689 | \fInumber\fR and \fIwhat\fR. | |
690 | \fINumber\fR must be an integer. | |
691 | \fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation | |
692 | of one of these. | |
693 | If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by | |
694 | \fInumber\fR average-width characters on the display; if it is | |
695 | \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. | |
696 | If \fInumber\fR is negative then characters farther to the left | |
697 | become visible; if it is positive then characters farther to the right | |
698 | become visible. | |
699 | .RE | |
700 | ||
701 | .SH "DEFAULT BINDINGS" | |
702 | .PP | |
703 | Tk automatically creates class bindings for spinboxes that give them | |
704 | the following default behavior. | |
705 | In the descriptions below, ``word'' refers to a contiguous group | |
706 | of letters, digits, or ``_'' characters, or any single character | |
707 | other than these. | |
708 | .IP [1] | |
709 | Clicking mouse button 1 positions the insertion cursor | |
710 | just before the character underneath the mouse cursor, sets the | |
711 | input focus to this widget, and clears any selection in the widget. | |
712 | Dragging with mouse button 1 strokes out a selection between | |
713 | the insertion cursor and the character under the mouse. | |
714 | .IP [2] | |
715 | Double-clicking with mouse button 1 selects the word under the mouse | |
716 | and positions the insertion cursor at the beginning of the word. | |
717 | Dragging after a double click will stroke out a selection consisting | |
718 | of whole words. | |
719 | .IP [3] | |
720 | Triple-clicking with mouse button 1 selects all of the text in the | |
721 | spinbox and positions the insertion cursor before the first character. | |
722 | .IP [4] | |
723 | The ends of the selection can be adjusted by dragging with mouse | |
724 | button 1 while the Shift key is down; this will adjust the end | |
725 | of the selection that was nearest to the mouse cursor when button | |
726 | 1 was pressed. | |
727 | If the button is double-clicked before dragging then the selection | |
728 | will be adjusted in units of whole words. | |
729 | .IP [5] | |
730 | Clicking mouse button 1 with the Control key down will position the | |
731 | insertion cursor in the spinbox without affecting the selection. | |
732 | .IP [6] | |
733 | If any normal printing characters are typed in a spinbox, they are | |
734 | inserted at the point of the insertion cursor. | |
735 | .IP [7] | |
736 | The view in the spinbox can be adjusted by dragging with mouse button 2. | |
737 | If mouse button 2 is clicked without moving the mouse, the selection | |
738 | is copied into the spinbox at the position of the mouse cursor. | |
739 | .IP [8] | |
740 | If the mouse is dragged out of the spinbox on the left or right sides | |
741 | while button 1 is pressed, the spinbox will automatically scroll to | |
742 | make more text visible (if there is more text off-screen on the side | |
743 | where the mouse left the window). | |
744 | .IP [9] | |
745 | The Left and Right keys move the insertion cursor one character to the | |
746 | left or right; they also clear any selection in the spinbox and set | |
747 | the selection anchor. | |
748 | If Left or Right is typed with the Shift key down, then the insertion | |
749 | cursor moves and the selection is extended to include the new character. | |
750 | Control-Left and Control-Right move the insertion cursor by words, and | |
751 | Control-Shift-Left and Control-Shift-Right move the insertion cursor | |
752 | by words and also extend the selection. | |
753 | Control-b and Control-f behave the same as Left and Right, respectively. | |
754 | Meta-b and Meta-f behave the same as Control-Left and Control-Right, | |
755 | respectively. | |
756 | .IP [10] | |
757 | The Home key, or Control-a, will move the insertion cursor to the | |
758 | beginning of the spinbox and clear any selection in the spinbox. | |
759 | Shift-Home moves the insertion cursor to the beginning of the spinbox | |
760 | and also extends the selection to that point. | |
761 | .IP [11] | |
762 | The End key, or Control-e, will move the insertion cursor to the | |
763 | end of the spinbox and clear any selection in the spinbox. | |
764 | Shift-End moves the cursor to the end and extends the selection | |
765 | to that point. | |
766 | .IP [12] | |
767 | The Select key and Control-Space set the selection anchor to the position | |
768 | of the insertion cursor. They don't affect the current selection. | |
769 | Shift-Select and Control-Shift-Space adjust the selection to the | |
770 | current position of the insertion cursor, selecting from the anchor | |
771 | to the insertion cursor if there was not any selection previously. | |
772 | .IP [13] | |
773 | Control-/ selects all the text in the spinbox. | |
774 | .IP [14] | |
775 | Control-\e clears any selection in the spinbox. | |
776 | .IP [15] | |
777 | The F16 key (labelled Copy on many Sun workstations) or Meta-w | |
778 | copies the selection in the widget to the clipboard, if there is a selection. | |
779 | .IP [16] | |
780 | The F20 key (labelled Cut on many Sun workstations) or Control-w | |
781 | copies the selection in the widget to the clipboard and deletes | |
782 | the selection. | |
783 | If there is no selection in the widget then these keys have no effect. | |
784 | .IP [17] | |
785 | The F18 key (labelled Paste on many Sun workstations) or Control-y | |
786 | inserts the contents of the clipboard at the position of the | |
787 | insertion cursor. | |
788 | .IP [18] | |
789 | The Delete key deletes the selection, if there is one in the spinbox. | |
790 | If there is no selection, it deletes the character to the right of | |
791 | the insertion cursor. | |
792 | .IP [19] | |
793 | The BackSpace key and Control-h delete the selection, if there is one | |
794 | in the spinbox. | |
795 | If there is no selection, it deletes the character to the left of | |
796 | the insertion cursor. | |
797 | .IP [20] | |
798 | Control-d deletes the character to the right of the insertion cursor. | |
799 | .IP [21] | |
800 | Meta-d deletes the word to the right of the insertion cursor. | |
801 | .IP [22] | |
802 | Control-k deletes all the characters to the right of the insertion | |
803 | cursor. | |
804 | .IP [23] | |
805 | Control-t reverses the order of the two characters to the right of | |
806 | the insertion cursor. | |
807 | .PP | |
808 | If the spinbox is disabled using the \fB\-state\fR option, then the spinbox's | |
809 | view can still be adjusted and text in the spinbox can still be selected, | |
810 | but no insertion cursor will be displayed and no text modifications will | |
811 | take place. | |
812 | .PP | |
813 | The behavior of spinboxes can be changed by defining new bindings for | |
814 | individual widgets or by redefining the class bindings. | |
815 | ||
816 | .SH KEYWORDS | |
817 | spinbox, entry, widget |