OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/base.git] / util / src / TclTk / tk8.6.12 / doc / ttk_entry.n
1 '\"
2 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
3 '\" Copyright (c) 1998-2000 Scriptics Corporation.
4 '\" Copyright (c) 2004 Joe English
5 '\"
6 '\" See the file "license.terms" for information on usage and redistribution
7 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
8 '\"
9 .TH ttk::entry n 8.5 Tk "Tk Themed Widget"
10 .so man.macros
11 .BS
12 .SH NAME
13 ttk::entry \- Editable text field widget
14 .SH SYNOPSIS
15 \fBttk::entry\fR \fIpathName \fR?\fIoptions\fR?
16 .BE
17 .SH DESCRIPTION
18 .PP
19 An \fBttk::entry\fR widget displays a one-line text string and
20 allows that string to be edited by the user.
21 The value of the string may be linked to a Tcl variable
22 with the \fB\-textvariable\fR option.
23 Entry widgets support horizontal scrolling with the
24 standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command.
25 .SO ttk_widget
26 \-class \-cursor
27 \-font  \-foreground
28 \-style
29 \-takefocus     \-xscrollcommand
30 .SE
31 .SH "WIDGET-SPECIFIC OPTIONS"
32 .OP \-exportselection exportSelection ExportSelection
33 A boolean value specifying whether or not
34 a selection in the widget should be linked to the X selection.
35 If the selection is exported, then selecting in the widget deselects
36 the current X selection, selecting outside the widget deselects any
37 widget selection, and the widget will respond to selection retrieval
38 requests when it has a selection.
39 .\" MAYBE: .OP \-insertbackground insertBackground Foreground
40 .\" MAYBE: .OP \-insertwidth insertWidth InsertWidth
41 .OP \-invalidcommand invalidCommand InvalidCommand
42 A script template to evaluate whenever the \fB\-validatecommand\fR returns 0.
43 See \fBVALIDATION\fR below for more information.
44 .OP \-justify justify Justify
45 Specifies how the text is aligned within the entry widget.
46 One of \fBleft\fR, \fBcenter\fR, or \fBright\fR.
47 .\" MAYBE: .OP \-selectbackground selectBackground Foreground
48 .\" MAYBE: .OP \-selectborderwidth selectBorderWidth BorderWidth
49 .\" MAYBE: .OP \-selectforeground selectForeground Background
50 .OP \-show show Show
51 If this option is specified, then the true contents of the entry
52 are not displayed in the window.
53 Instead, each character in the entry's value will be displayed as
54 the first character in the value of this option, such as
55 .QW *
56 or a bullet.
57 This is useful, for example, if the entry is to be used to enter
58 a password.
59 If characters in the entry are selected and copied elsewhere, the
60 information copied will be what is displayed, not the true contents
61 of the entry.
62 .OP \-state state State
63 Compatibility option; see \fIttk::widget(n)\fR for details.
64 Specifies one of three states for the entry,
65 \fBnormal\fR, \fBdisabled\fR, or \fBreadonly\fR.
66 See \fBWIDGET STATES\fR, below.
67 .OP \-textvariable textVariable Variable
68 Specifies the name of a global variable whose value is linked
69 to the entry widget's contents.
70 Whenever the variable changes value, the widget's contents are updated,
71 and vice versa.
72 .OP \-validate validate Validate
73 Specifies the mode in which validation should operate:
74 \fBnone\fR, \fBfocus\fR, \fBfocusin\fR, \fBfocusout\fR, \fBkey\fR, or \fBall\fR.
75 Default is \fBnone\fR, meaning that validation is disabled.
76 See \fBVALIDATION\fR below.
77 .OP \-validatecommand validateCommand ValidateCommand
78 A script template to evaluate whenever validation is triggered.
79 If set to the empty string (the default), validation is disabled.
80 The script must return a boolean value.
81 See \fBVALIDATION\fR below.
82 .OP \-width width Width
83 Specifies an integer value indicating the desired width of the entry window,
84 in average-size characters of the widget's font.
85 .\" Not in ttk: If the value is less than or equal to zero, the widget picks a
86 .\" Not in ttk: size just large enough to hold its current text.
87 .SH NOTES
88 .PP
89 A portion of the entry may be selected as described below.
90 If an entry is exporting its selection (see the \fB\-exportselection\fR
91 option), then it will observe the standard X11 protocols for handling the
92 selection;  entry selections are available as type \fBSTRING\fR.
93 Entries also observe the standard Tk rules for dealing with the
94 input focus.  When an entry has the input focus it displays an
95 \fIinsert cursor\fR to indicate where new characters will be
96 inserted.
97 .PP
98 Entries are capable of displaying strings that are too long to
99 fit entirely within the widget's window.  In this case, only a
100 portion of the string will be displayed;  commands described below
101 may be used to change the view in the window.  Entries use
102 the standard \fB\-xscrollcommand\fR mechanism for interacting with
103 scrollbars (see the description of the \fB\-xscrollcommand\fR option
104 for details).
105 .SH "INDICES"
106 .PP
107 Many of the \fBentry\fR widget commands take one or more indices as
108 arguments.  An index specifies a particular character in the entry's
109 string, in any of the following ways:
110 .IP \fInumber\fR
111 Specifies the character as a numerical index, where 0 corresponds
112 to the first character in the string.
113 .IP \fB@\fInumber\fR
114 In this form, \fInumber\fR is treated as an x-coordinate in the
115 entry's window;  the character spanning that x-coordinate is used.
116 For example,
117 .QW \fB@0\fR
118 indicates the left-most character in the window.
119 .IP \fBend\fR
120 Indicates the character just after the last one in the entry's string.
121 This is equivalent to specifying a numerical index equal to the length
122 of the entry's string.
123 .IP \fBinsert\fR
124 Indicates the character adjacent to and immediately following the
125 insert cursor.
126 .IP \fBsel.first\fR
127 Indicates the first character in the selection.  It is an error to
128 use this form if the selection is not in the entry window.
129 .IP \fBsel.last\fR
130 Indicates the character just after the last one in the selection.
131 It is an error to use this form if the selection is not in the
132 entry window.
133 .LP
134 Abbreviations may be used for any of the forms above, e.g.\|
135 .QW \fBe\fR
136 or
137 .QW \fBsel.l\fR .
138 In general, out-of-range indices are automatically rounded to the
139 nearest legal value.
140 .SH "WIDGET COMMAND"
141 .PP
142 The following subcommands are possible for entry widgets:
143 .TP
144 \fIpathName \fBbbox \fIindex\fR
145 Returns a list of four numbers describing the bounding box of the
146 character given by \fIindex\fR.
147 The first two elements of the list give the x and y coordinates of
148 the upper-left corner of the screen area covered by the character
149 (in pixels relative to the widget) and the last two elements give
150 the width and height of the character, in pixels.
151 The bounding box may refer to a region outside the visible area
152 of the window.
153 '\".TP
154 '\"\fIpathName \fBcget\fR \fIoption\fR
155 '\"Returns the current value of the specified \fIoption\fR.
156 '\"See \fIttk::widget(n)\fR.
157 '\".TP
158 '\"\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
159 '\"Modify or query widget options.
160 '\"See \fIttk::widget(n)\fR.
161 .TP
162 \fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
163 Delete one or more elements of the entry.
164 \fIFirst\fR is the index of the first character to delete, and
165 \fIlast\fR is the index of the character just after the last
166 one to delete.
167 If \fIlast\fR is not specified it defaults to \fIfirst\fR+1,
168 i.e. a single character is deleted.
169 This command returns the empty string.
170 .TP
171 \fIpathName \fBget\fR
172 Returns the entry's string.
173 .TP
174 \fIpathName \fBicursor \fIindex\fR
175 Arrange for the insert cursor to be displayed just before the character
176 given by \fIindex\fR.  Returns the empty string.
177 '\".TP
178 '\"\fIpathName \fBidentify \fIx y\fR
179 '\"Returns the name of the element at position \fIx\fR, \fIy\fR,
180 '\"or the empty string if the coordinates are outside the window.
181 .TP
182 \fIpathName \fBindex\fI index\fR
183 Returns the numerical index corresponding to \fIindex\fR.
184 .TP
185 \fIpathName \fBinsert \fIindex string\fR
186 Insert \fIstring\fR just before the character
187 indicated by \fIindex\fR.  Returns the empty string.
188 '\".TP
189 '\"\fIpathName \fBinstate \fIstatespec\fR ?\fIscript\fR?
190 '\"Test the widget state.
191 '\"See \fIttk::widget(n)\fR.
192 .TP
193 \fIpathName \fBselection \fIoption arg\fR
194 This command is used to adjust the selection within an entry.  It
195 has several forms, depending on \fIoption\fR:
196 .RS
197 .TP
198 \fIpathName \fBselection clear\fR
199 Clear the selection if it is currently in this widget.
200 If the selection is not in this widget then the command has no effect.
201 Returns the empty string.
202 .TP
203 \fIpathName \fBselection present\fR
204 Returns 1 if there is are characters selected in the entry,
205 0 if nothing is selected.
206 .TP
207 \fIpathName \fBselection range \fIstart\fR \fIend\fR
208 Sets the selection to include the characters starting with
209 the one indexed by \fIstart\fR and ending with the one just
210 before \fIend\fR.
211 If \fIend\fR refers to the same character as \fIstart\fR or an
212 earlier one, then the entry's selection is cleared.
213 .RE
214 '\".TP
215 '\"\fIpathName \fBstate\fR ?\fIstateSpec\fR?
216 '\"Modify or query the widget state.
217 '\"See \fIttk::widget(n)\fR.
218 .TP
219 \fIpathName \fBvalidate\fR
220 Force revalidation, independent of the conditions specified
221 by the \fB\-validate\fR option.
222 Returns 0 if validation fails, 1 if it succeeds.
223 Sets or clears the \fBinvalid\fR state accordingly.
224 See \fBVALIDATION\fR below for more details.
225 .PP
226 The entry widget also supports the following generic \fBttk::widget\fR
227 widget subcommands (see \fIttk::widget(n)\fR for details):
228 .DS
229 .ta 5.5c 11c
230 \fBcget\fR      \fBconfigure\fR \fBidentify\fR
231 \fBinstate\fR   \fBstate\fR     \fBxview\fR
232 .DE
233 .SH VALIDATION
234 .PP
235 The \fB\-validate\fR, \fB\-validatecommand\fR, and \fB\-invalidcommand\fR
236 options are used to enable entry widget validation.
237 .SS "VALIDATION MODES"
238 .PP
239 There are two main validation modes: \fIprevalidation\fR,
240 in which the \fB\-validatecommand\fR is evaluated prior to each edit
241 and the return value is used to determine whether to accept
242 or reject the change;
243 and \fIrevalidation\fR, in which the \fB\-validatecommand\fR is
244 evaluated to determine whether the current value is valid.
245 .PP
246 The \fB\-validate\fR option determines when validation occurs;
247 it may be set to any of the following values:
248 .RS
249 .IP \fBnone\fR
250 Default.  This means validation will only occur when
251 specifically requested by the \fBvalidate\fR widget command.
252 .IP \fBkey\fR
253 The entry will be prevalidated prior to each edit
254 (specifically, whenever the \fBinsert\fR or \fBdelete\fR
255 widget commands are called).
256 If prevalidation fails, the edit is rejected.
257 .IP \fBfocus\fR
258 The entry is revalidated when the entry receives or loses focus.
259 .IP \fBfocusin\fR
260 The entry is revalidated when the entry receives focus.
261 .IP \fBfocusout\fR
262 The entry is revalidated when the entry loses focus.
263 .IP \fBall\fR
264 Validation is performed for all above conditions.
265 .RE
266 .PP
267 The \fB\-invalidcommand\fR is evaluated whenever
268 the \fB\-validatecommand\fR returns a false value.
269 .PP
270 The \fB\-validatecommand\fR and \fB\-invalidcommand\fR
271 may modify the entry widget's value
272 via the widget \fBinsert\fR or \fBdelete\fR commands,
273 or by setting the linked \fB\-textvariable\fR.
274 If either does so during prevalidation,
275 then the edit is rejected
276 regardless of the value returned by the \fB\-validatecommand\fR.
277 .PP
278 If \fB\-validatecommand\fR is empty (the default),
279 validation always succeeds.
280 .SS "VALIDATION SCRIPT SUBSTITUTIONS"
281 .PP
282 It is possible to perform percent substitutions on the
283 \fB\-validatecommand\fR and \fB\-invalidcommand\fR,
284 just as in a \fBbind\fR script.
285 The following substitutions are recognized:
286 .RS
287 .IP \fB%d\fR
288 Type of action: 1 for \fBinsert\fR prevalidation,
289 0 for \fBdelete\fR prevalidation,
290 or \-1 for revalidation.
291 .IP \fB%i\fR
292 Index of character string to be inserted/deleted, if any, otherwise \-1.
293 .IP \fB%P\fR
294 In prevalidation, the new value of the entry if the edit is accepted.
295 In revalidation, the current value of the entry.
296 .IP \fB%s\fR
297 The current value of entry prior to editing.
298 .IP \fB%S\fR
299 The text string being inserted/deleted, if any, {} otherwise.
300 .IP \fB%v\fR
301 The current value of the \fB\-validate\fR option.
302 .IP \fB%V\fR
303 The validation condition that triggered the callback
304 (\fBkey\fR, \fBfocusin\fR, \fBfocusout\fR, or \fBforced\fR).
305 .IP \fB%W\fR
306 The name of the entry widget.
307 .RE
308 .SS "DIFFERENCES FROM TK ENTRY WIDGET VALIDATION"
309 .PP
310 The standard Tk entry widget automatically disables validation
311 (by setting \fB\-validate\fR to \fBnone\fR)
312 if the \fB\-validatecommand\fR or \fB\-invalidcommand\fR modifies
313 the entry's value.
314 The Tk themed entry widget only disables validation if one
315 of the validation scripts raises an error, or if \fB\-validatecommand\fR
316 does not return a valid boolean value.
317 (Thus, it is not necessary to re-enable validation after
318 modifying the entry value in a validation script).
319 .PP
320 In addition, the standard entry widget invokes validation whenever the linked
321 \fB\-textvariable\fR is modified; the Tk themed entry widget does not.
322 .SH "DEFAULT BINDINGS"
323 .PP
324 The entry widget's default bindings enable the following behavior.
325 In the descriptions below,
326 .QW word
327 refers to a contiguous group of letters, digits, or
328 .QW _
329 characters, or any single character other than these.
330 .IP \0\(bu 4
331 Clicking mouse button 1 positions the insert cursor
332 just before the character underneath the mouse cursor, sets the
333 input focus to this widget, and clears any selection in the widget.
334 Dragging with mouse button 1 down strokes out a selection between
335 the insert cursor and the character under the mouse.
336 .IP \0\(bu 4
337 Double-clicking with mouse button 1 selects the word under the mouse
338 and positions the insert cursor at the end of the word.
339 Dragging after a double click strokes out a selection consisting
340 of whole words.
341 .IP \0\(bu 4
342 Triple-clicking with mouse button 1 selects all of the text in the
343 entry and positions the insert cursor at the end of the line.
344 .IP \0\(bu 4
345 The ends of the selection can be adjusted by dragging with mouse
346 button 1 while the Shift key is down.
347 If the button is double-clicked before dragging then the selection
348 will be adjusted in units of whole words.
349 .IP \0\(bu 4
350 Clicking mouse button 1 with the Control key down will position the
351 insert cursor in the entry without affecting the selection.
352 .IP \0\(bu 4
353 If any normal printing characters are typed in an entry, they are
354 inserted at the point of the insert cursor.
355 .IP \0\(bu 4
356 The view in the entry can be adjusted by dragging with the middle
357 mouse button (button 2, or button 3 in TkAqua). If the middle mouse
358 button is clicked without moving the mouse, the selection is copied
359 into the entry at the position of the mouse cursor.
360 .IP \0\(bu 4
361 If the mouse is dragged out of the entry on the left or right sides
362 while button 1 is pressed, the entry will automatically scroll to
363 make more text visible (if there is more text off-screen on the side
364 where the mouse left the window).
365 .IP \0\(bu 4
366 The Left and Right keys move the insert cursor one character to the
367 left or right;  they also clear any selection in the entry.
368 If Left or Right is typed with the Shift key down, then the insertion
369 cursor moves and the selection is extended to include the new character.
370 Control-Left and Control-Right move the insert cursor by words, and
371 Control-Shift-Left and Control-Shift-Right move the insert cursor
372 by words and also extend the selection.
373 Control-b and Control-f behave the same as Left and Right, respectively.
374 .IP \0\(bu 4
375 The Home key and Control-a move the insert cursor to the
376 beginning of the entry and clear any selection in the entry.
377 Shift-Home moves the insert cursor to the beginning of the entry
378 and extends the selection to that point.
379 .IP \0\(bu 4
380 The End key and Control-e move the insert cursor to the
381 end of the entry and clear any selection in the entry.
382 Shift-End moves the cursor to the end and extends the selection
383 to that point.
384 .IP \0\(bu 4
385 Control-/ selects all the text in the entry.
386 .IP \0\(bu 4
387 Control-\e clears any selection in the entry.
388 .IP \0\(bu 4
389 The standard Tk <<Cut>>, <<Copy>>, <<Paste>>, and <<Clear>>
390 virtual events operate on the selection in the expected manner.
391 .IP \0\(bu 4
392 The Delete key deletes the selection, if there is one in the entry.
393 If there is no selection, it deletes the character to the right of
394 the insert cursor.
395 .IP \0\(bu 4
396 The BackSpace key and Control-h delete the selection, if there is one
397 in the entry.
398 If there is no selection, it deletes the character to the left of
399 the insert cursor.
400 .IP \0\(bu 4
401 Control-d deletes the character to the right of the insert cursor.
402 .IP \0\(bu 4
403 Control-k deletes all the characters to the right of the insertion
404 cursor.
405 .SH "WIDGET STATES"
406 .PP
407 In the \fBdisabled\fR state,
408 the entry cannot be edited and the text cannot be selected.
409 In the \fBreadonly\fR state,
410 no insert cursor is displayed and
411 the entry cannot be edited
412 (specifically: the \fBinsert\fR and \fBdelete\fR commands have no effect).
413 The \fBdisabled\fR state is the same as \fBreadonly\fR,
414 and in addition text cannot be selected.
415 .PP
416 Note that changes to the linked \fB\-textvariable\fR will
417 still be reflected in the entry, even if it is disabled or readonly.
418 .PP
419 Typically, the text is
420 .QW grayed-out
421 in the \fBdisabled\fR state,
422 and a different background is used in the \fBreadonly\fR state.
423 .PP
424 The entry widget sets the \fBinvalid\fR state if revalidation fails,
425 and clears it whenever validation succeeds.
426 .SH "STYLING OPTIONS"
427 .PP
428 The class name for a \fBttk::entry\fP is \fBTEntry\fP.
429 .PP
430 Dynamic states: \fBdisabled\fP, \fBfocus\fP, \fBreadonly\fP.
431 .PP
432 \fBTEntry\fP styling options configurable with \fBttk::style\fP
433 are:
434 .PP
435 \fB\-background\fP \fIcolor\fP
436 .RS
437 For backwards compatibility, when using the aqua theme (for macOS), this
438 option behaves as an alias for the \fB\-fieldbackground\fP provided that no
439 value is specified for \fB\-fieldbackground\fP. Otherwise it is ignored.
440 .RE
441 \fB\-bordercolor\fP \fIcolor\fP
442 .br
443 \fB\-darkcolor\fP \fIcolor\fP
444 .br
445 \fB\-fieldbackground\fP \fIcolor\fP
446 .RS
447 Some themes use a graphical background and their field background colors cannot be changed.
448 .RE
449 \fB\-foreground\fP \fIcolor\fP
450 .br
451 \fB\-insertcolor\fP \fIcolor\fP
452 .br
453 \fB\-insertwidth\fP \fIamount\fP
454 .br
455 \fB\-lightcolor\fP \fIcolor\fP
456 .br
457 \fB\-padding\fP \fIpadding\fP
458 .br
459 \fB\-relief\fP \fIrelief\fP
460 .br
461 \fB\-selectbackground\fP \fIcolor\fP
462 .br
463 \fB\-selectborderwidth\fP \fIamount\fP
464 .br
465 \fB\-selectforeground\fP \fIcolor\fP
466 .PP
467 See the \fBttk::style\fP manual page for information on how to configure
468 ttk styles.
469 .SH "SEE ALSO"
470 ttk::widget(n), entry(n)
471 .SH KEYWORDS
472 entry, widget, text field
473 '\" Local Variables:
474 '\" mode: nroff
475 '\" End: