Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / Entry.pod
CommitLineData
86530b38
AT
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
10Tk::Entry - Create and manipulate Entry widgets
11
12=for category Tk Widget Classes
13
14=head1 SYNOPSIS
15
16S< >I<$entry> = I<$parent>-E<gt>B<Entry>(?I<options>?);
17
18=head1 STANDARD OPTIONS
19
20B<-background> B<-highlightbackground> B<-insertontime> B<-selectforeground>
21B<-borderwidth> B<-highlightcolor> B<-insertwidth> B<-takefocus>
22B<-cursor> B<-highlightthickness> B<-justify> B<-textvariable>
23B<-exportselection> B<-insertbackground> B<-relief> B<-xscrollcommand>
24B<-font> B<-insertborderwidth> B<-selectbackground>
25B<-foreground> B<-insertofftime> B<-selectborderwidth>
26
27=head1 WIDGET-SPECIFIC OPTIONS
28
29=over 4
30
31=item Name: B<invalidCommand>
32
33=item Class: B<InvalidCommand>
34
35=item Switch: B<-invalidcommand>
36
37=item Alias: B<-invcmd>
38
39Specifies a script to eval when B<validateCommand> returns 0.
40Setting it to <undef> disables this feature (the default). The best use
41of this option is to set it to I<bell>. See B<Validation>
42below for more information.
43
44=item Name: B<show>
45
46=item Class: B<Show>
47
48=item Switch: B<-show>
49
50If this option is specified, then the true contents of the entry
51are not displayed in the window.
52Instead, each character in the entry's value will be displayed as
53the first character in the value of this option, such as ``*''.
54This is useful, for example, if the entry is to be used to enter
55a password.
56If characters in the entry are selected and copied elsewhere, the
57information copied will be what is displayed, not the true contents
58of the entry.
59
60=item Name: B<state>
61
62=item Class: B<State>
63
64=item Switch: B<-state>
65
66Specifies one of two states for the entry: B<normal> or B<disabled>.
67If the entry is disabled then the value may not be changed using widget
68methods and no insertion cursor will be displayed, even if the input focus is
69in the widget.
70
71=item Name: B<validate>
72
73=item Class: B<Validate>
74
75=item Switch: B<-validate>
76
77Specifies the mode in which validation should operate: B<none>,
78B<focus>, B<focusin>, B<focusout>, B<key>, or B<all>.
79It defaults to B<none>. When you want validation, you must explicitly
80state which mode you wish to use. See B<Validation> below for more.
81
82=item Name: B<validateCommand>
83
84=item Class: B<ValidateCommand>
85
86=item Switch: B<-validatecommand>
87
88=item Alias: B<-vcmd>
89
90Specifies a script to eval when you want to validate the input into
91the entry widget. Setting it to C<undef> disables this feature (the default).
92This command must return a valid boolean value. If it returns 0 (or
93the valid boolean equivalent) then it means you reject the new edition
94and it will not occur and the B<invalidCommand> will be evaluated if it
95is set. If it returns 1, then the new edition occurs.
96See B<Validation> below for more information.
97
98=item Name: B<width>
99
100=item Class: B<Width>
101
102=item Switch: B<-width>
103
104Specifies an integer value indicating the desired width of the entry window,
105in average-size characters of the widget's font.
106If the value is less than or equal to zero, the widget picks a
107size just large enough to hold its current text.
108
109=back
110
111=head1 DESCRIPTION
112
113The B<Entry> method creates a new window (given by the
114$entry argument) and makes it into an entry widget.
115Additional options, described above, may be specified on the
116command line or in the option database
117to configure aspects of the entry such as its colors, font,
118and relief. The B<entry> command returns its
119$entry argument. At the time this command is invoked,
120there must not exist a window named $entry, but
121$entry's parent must exist.
122
123An entry is a widget that displays a one-line text string and
124allows that string to be edited using methods described below, which
125are typically bound to keystrokes and mouse actions.
126When first created, an entry's string is empty.
127A portion of the entry may be selected as described below.
128If an entry is exporting its selection (see the B<exportSelection>
129option), then it will observe the standard X11 protocols for handling the
130selection; entry selections are available as type B<STRING>.
131Entries also observe the standard Tk rules for dealing with the
132input focus. When an entry has the input focus it displays an
133I<insertion cursor> to indicate where new characters will be
134inserted.
135
136Entries are capable of displaying strings that are too long to
137fit entirely within the widget's window. In this case, only a
138portion of the string will be displayed; methods described below
139may be used to change the view in the window. Entries use
140the standard B<xScrollCommand> mechanism for interacting with
141scrollbars (see the description of the B<-xscrollcommand> option
142for details). They also support scanning, as described below.
143
144=head1 VALIDATION
145
146Validation of entry widgets is derived from part of the patch written by
147jhobbs@cs.uoregon.edu. This works by setting the B<validateCommand>
148option to a callback which will be evaluated according to the B<validate>
149option as follows:
150
151=over 4
152
153=item B<none>
154
155Default. This means no validation will occur.
156
157=item B<focus>
158
159B<validateCommand> will be called when the entry receives or
160loses focus.
161
162=item B<focusin>
163
164B<validateCommand> will be called when the entry receives focus.
165
166=item B<focusout>
167
168B<validateCommand> will be called when the entry loses focus.
169
170=item B<key>
171
172B<validateCommand> will be called when the entry is edited.
173
174=item B<all>
175
176B<validateCommand> will be called for all above conditions.
177
178=back
179
180The B<validateCommand> and B<invalidCommand> are called with the following
181arguments:
182
183=over 4
184
185=item * The proposed value of the entry. If you are configuring the
186entry widget to have a new textvariable, this will be the value of that
187textvariable.
188
189=item * The characters to be added (or deleted). This will be C<undef>
190if validation is due to focus, explcit call to validate or if change
191is due to C<-textvariable> changing.
192
193=item * The current value of entry i.e. before the proposed change.
194
195=item * index of char string to be added/deleted, if any. -1 otherwise
196
197=item * type of action. 1 == INSERT, 0 == DELETE,
198-1 if it's a forced validation or textvariable validation
199
200=back
201
202In general, the B<textVariable> and B<validateCommand> can be
203dangerous to mix. If you try set the B<textVariable>
204to something that the B<validateCommand> will not accept it will
205be set back to the value of the entry widget.
206Using the B<textVariable> for read-only purposes will never cause problems.
207
208The B<validateCommand> will turn itself off by setting
209B<validate> to B<none> when an error occurs, for example
210when the B<validateCommand> or B<invalidCommand> encounters
211an error in its script while evaluating, or
212B<validateCommand> does not return a valid boolean value.
213
214With the perl/Tk version B<validate> option is supposed to be
215"suspended" while executing the B<validateCommand> or the B<invalidCommand>.
216This is experimental but in theory either callback can "correct" the
217value of the widget, and override the proposed change. (B<validateCommand>
218should still return false to inhibit the change from happening when
219it returns.)
220
221=head1 WIDGET METHODS
222
223The B<Entry> method creates a widget object.
224This object supports the B<configure> and B<cget> methods
225described in L<Tk::options> which can be used to enquire and
226modify the options described above.
227The widget also inherits all the methods provided by the generic
228L<Tk::Widget|Tk::Widget> class.
229
230Many of the additional methods for entries take one or more indices as
231arguments. An index specifies a particular character in the entry's
232string, in any of the following ways:
233
234=over 4
235
236=item I<number>
237
238Specifies the character as a numerical index, where 0 corresponds
239to the first character in the string.
240
241=item B<anchor>
242
243Indicates the anchor point for the selection, which is set with the
244B<selectionFrom> and B<selectionAdjust> methods.
245
246=item B<end>
247
248Indicates the character just after the last one in the entry's string.
249This is equivalent to specifying a numerical index equal to the length
250of the entry's string.
251
252=item B<insert>
253
254Indicates the character adjacent to and immediately following the
255insertion cursor.
256
257=item B<sel.first>
258
259Indicates the first character in the selection. It is an error to
260use this form if the selection isn't in the entry window.
261
262=item B<sel.last>
263
264Indicates the character just after the last one in the selection.
265It is an error to use this form if the selection isn't in the
266entry window.
267
268=item B<@>I<number>
269
270In this form, I<number> is treated as an x-coordinate in the
271entry's window; the character spanning that x-coordinate is used.
272For example, ``B<@0>'' indicates the left-most character in the
273window.
274
275=back
276
277Abbreviations may be used for any of the forms above, e.g. ``B<e>''
278or ``B<sel.f>''. In general, out-of-range indices are automatically
279rounded to the nearest legal value.
280
281The following additional methods are available for entry widgets:
282
283=over 4
284
285=item I<$entry>-E<gt>B<bbox>(I<index>)
286
287Returns a list of four numbers describing the bounding box of the
288character given by I<index>.
289The first two elements of the list give the x and y coordinates of
290the upper-left corner of the screen area covered by the character
291(in pixels relative to the widget) and the last two elements give
292the width and height of the character, in pixels.
293The bounding box may refer to a region outside the visible area
294of the window.
295
296=item I<$entry>-E<gt>B<delete>(I<first, >?I<last>?)
297
298Returns the current value of the configuration option given
299by I<option>.
300I<Option> may have any of the values accepted by the B<entry>
301command.
302
303=item I<$entry>-E<gt>B<configure>(?I<option>?, ?I<value, option, value, ...>?)
304
305Query or modify the configuration options of the widget.
306If no I<option> is specified, returns a list describing all of
307the available options for $entry (see L<Tk::configure> for
308information on the format of this list). If I<option> is specified
309with no I<value>, then the command returns a list describing the
310one named option (this list will be identical to the corresponding
311sublist of the value returned if no I<option> is specified). If
312one or more I<option-value> pairs are specified, then the command
313modifies the given widget option(s) to have the given value(s); in
314this case the command returns an empty string.
315I<Option> may have any of the values accepted by the B<entry>
316command.
317
318=item I<$entry>-E<gt>B<delete>(I<first, >?I<last>?)
319
320Delete one or more elements of the entry.
321I<First> is the index of the first character to delete, and
322I<last> is the index of the character just after the last
323one to delete.
324If I<last> isn't specified it defaults to I<first>+1,
325i.e. a single character is deleted.
326This method returns an empty string.
327
328=item I<$entry>-E<gt>B<get>
329
330Returns the entry's string.
331
332=item I<$entry>-E<gt>B<icursor>(I<index>)
333
334Arrange for the insertion cursor to be displayed just before the character
335given by I<index>. Returns an empty string.
336
337=item I<$entry>-E<gt>B<index>(I<index>)
338
339Returns the numerical index corresponding to I<index>.
340
341=item I<$entry>-E<gt>B<insert>(I<index, string>)
342
343Insert the characters of I<string> just before the character
344indicated by I<index>. Returns an empty string.
345
346=item I<$entry>->B<scan>(I<option, args>)
347
348=item I<$entry>->B<scan>I<Option>(I<args>)
349
350This method is used to implement scanning on entries. It has
351two forms, depending on I<Option>:
352
353=over 8
354
355=item I<$entry>->B<scanMark>(I<x>)
356
357Records I<x> and the current view in the entry widget; used in
358conjunction with later B<scanDragto> methods. Typically this
359method is associated with a mouse button press in the widget. It
360returns an empty string.
361
362=item I<$entry>->B<scanDragto>(I<x>)
363
364This method computes the difference between its I<x> argument
365and the I<x> argument to the last B<scanMark> method for
366the widget. It then adjusts the view left or right by 10 times the
367difference in x-coordinates. This method is typically associated
368with mouse motion events in the widget, to produce the effect of
369dragging the entry at high speed through the widget. The return
370value is an empty string.
371
372=back
373
374=item I<$entry>->B<selection>(I<option, arg>)
375
376=item I<$entry>->B<selection>I<Option>(I<arg>)
377
378This method is used to adjust the selection within an entry. It
379has several forms, depending on I<Option>:
380
381=over 8
382
383=item I<$entry>-E<gt>B<selectionAdjust>(I<index>)
384
385Locate the end of the selection nearest to the character given by
386I<index>, and adjust that end of the selection to be at I<index>
387(i.e including but not going beyond I<index>). The other
388end of the selection is made the anchor point for future
389B<selectionTo> methods. If the selection
390isn't currently in the entry, then a new selection is created to
391include the characters between I<index> and the most recent
392selection anchor point, inclusive.
393Returns an empty string.
394
395=item I<$entry>-E<gt>B<selectionClear>
396
397Clear the selection if it is currently in this widget. If the
398selection isn't in this widget then the method has no effect.
399Returns an empty string.
400
401=item I<$entry>-E<gt>B<selectionFrom>(I<index>)
402
403Set the selection anchor point to just before the character
404given by I<index>. Doesn't change the selection.
405Returns an empty string.
406
407=item I<$entry>-E<gt>B<selectionPresent>
408
409Returns 1 if there is are characters selected in the entry,
4100 if nothing is selected.
411
412=item I<$entry>-E<gt>B<selectionRange>(I<start, >I<end>)
413
414Sets the selection to include the characters starting with
415the one indexed by I<start> and ending with the one just
416before I<end>.
417If I<end> refers to the same character as I<start> or an
418earlier one, then the entry's selection is cleared.
419
420=item I<$entry>-E<gt>B<selectionTo>(I<index>)
421
422If I<index> is before the anchor point, set the selection
423to the characters from I<index> up to but not including
424the anchor point.
425If I<index> is the same as the anchor point, do nothing.
426If I<index> is after the anchor point, set the selection
427to the characters from the anchor point up to but not including
428I<index>.
429The anchor point is determined by the most recent B<selectionFrom>
430or B<selectionAdjust> method in this widget.
431If the selection isn't in this widget then a new selection is
432created using the most recent anchor point specified for the widget.
433Returns an empty string.
434
435=back
436
437=item I<$entry>-E<gt>B<validate>
438
439This command is used to force an evaluation of the B<validateCommand>
440independent of the conditions specified by the B<validate> option. It
441returns 0 or 1.
442
443=item I<$entry>-E<gt>B<xview>(I<args>)
444
445This command is used to query and change the horizontal position of the
446text in the widget's window. It can take any of the following
447forms:
448
449=over 8
450
451=item I<$entry>-E<gt>B<xview>
452
453Returns a list containing two elements.
454Each element is a real fraction between 0 and 1; together they describe
455the horizontal span that is visible in the window.
456For example, if the first element is .2 and the second element is .7,
45720% of the entry's text is off-screen to the left, the middle 50% is visible
458in the window, and 30% of the text is off-screen to the right.
459These are the same values passed to scrollbars via the B<-xscrollcommand>
460option.
461
462=item I<$entry>-E<gt>B<xview>(I<index>)
463
464Adjusts the view in the window so that the character given by I<index>
465is displayed at the left edge of the window.
466
467=item I<$entry>-E<gt>B<xviewMoveto>(I<fraction>)
468
469Adjusts the view in the window so that the character I<fraction> of the
470way through the text appears at the left edge of the window.
471I<Fraction> must be a fraction between 0 and 1.
472
473=item I<$entry>-E<gt>B<xviewScroll>(I<number, what>)
474
475This method shifts the view in the window left or right according to
476I<number> and I<what>.
477I<Number> must be an integer.
478I<What> must be either B<units> or B<pages> or an abbreviation
479of one of these.
480If I<what> is B<units>, the view adjusts left or right by
481I<number> average-width characters on the display; if it is
482B<pages> then the view adjusts by I<number> screenfuls.
483If I<number> is negative then characters farther to the left
484become visible; if it is positive then characters farther to the right
485become visible.
486
487=back
488
489=head1 DEFAULT BINDINGS
490
491Tk automatically creates class bindings for entries that give them
492the following default behavior.
493In the descriptions below, ``word'' refers to a contiguous group
494of letters, digits, or ``_'' characters, or any single character
495other than these.
496
497=over 4
498
499=item [1]
500
501Clicking mouse button 1 positions the insertion cursor
502just before the character underneath the mouse cursor, sets the
503input focus to this widget, and clears any selection in the widget.
504Dragging with mouse button 1 strokes out a selection between
505the insertion cursor and the character under the mouse.
506
507=item [2]
508
509Double-clicking with mouse button 1 selects the word under the mouse
510and positions the insertion cursor at the beginning of the word.
511Dragging after a double click will stroke out a selection consisting
512of whole words.
513
514=item [3]
515
516Triple-clicking with mouse button 1 selects all of the text in the
517entry and positions the insertion cursor before the first character.
518
519=item [4]
520
521The ends of the selection can be adjusted by dragging with mouse
522button 1 while the Shift key is down; this will adjust the end
523of the selection that was nearest to the mouse cursor when button
5241 was pressed.
525If the button is double-clicked before dragging then the selection
526will be adjusted in units of whole words.
527
528=item [5]
529
530Clicking mouse button 1 with the Control key down will position the
531insertion cursor in the entry without affecting the selection.
532
533=item [6]
534
535If any normal printing characters are typed in an entry, they are
536inserted at the point of the insertion cursor.
537
538=item [7]
539
540The view in the entry can be adjusted by dragging with mouse button 2.
541If mouse button 2 is clicked without moving the mouse, the selection
542is copied into the entry at the position of the mouse cursor.
543
544=item [8]
545
546If the mouse is dragged out of the entry on the left or right sides
547while button 1 is pressed, the entry will automatically scroll to
548make more text visible (if there is more text off-screen on the side
549where the mouse left the window).
550
551=item [9]
552
553The Left and Right keys move the insertion cursor one character to the
554left or right; they also clear any selection in the entry and set
555the selection anchor.
556If Left or Right is typed with the Shift key down, then the insertion
557cursor moves and the selection is extended to include the new character.
558Control-Left and Control-Right move the insertion cursor by words, and
559Control-Shift-Left and Control-Shift-Right move the insertion cursor
560by words and also extend the selection.
561Control-b and Control-f behave the same as Left and Right, respectively.
562Meta-b and Meta-f behave the same as Control-Left and Control-Right,
563respectively.
564
565=item [10]
566
567The Home key, or Control-a, will move the insertion cursor to the
568beginning of the entry and clear any selection in the entry.
569Shift-Home moves the insertion cursor to the beginning of the entry
570and also extends the selection to that point.
571
572=item [11]
573
574The End key, or Control-e, will move the insertion cursor to the
575end of the entry and clear any selection in the entry.
576Shift-End moves the cursor to the end and extends the selection
577to that point.
578
579=item [12]
580
581The Select key and Control-Space set the selection anchor to the position
582of the insertion cursor. They don't affect the current selection.
583Shift-Select and Control-Shift-Space adjust the selection to the
584current position of the insertion cursor, selecting from the anchor
585to the insertion cursor if there was not any selection previously.
586
587=item [13]
588
589Control-/ selects all the text in the entry.
590
591=item [14]
592
593Control-\ clears any selection in the entry.
594
595=item [15]
596
597The F16 key (labelled Copy on many Sun workstations) or Meta-w
598copies the selection in the widget to the clipboard, if there is a selection.
599
600=item [16]
601
602The F20 key (labelled Cut on many Sun workstations) or Control-w
603copies the selection in the widget to the clipboard and deletes
604the selection.
605If there is no selection in the widget then these keys have no effect.
606
607=item [17]
608
609The F18 key (labelled Paste on many Sun workstations) or Control-y
610inserts the contents of the clipboard at the position of the
611insertion cursor.
612
613=item [18]
614
615The Delete key deletes the selection, if there is one in the entry.
616If there is no selection, it deletes the character to the right of
617the insertion cursor.
618
619=item [19]
620
621The BackSpace key and Control-h delete the selection, if there is one
622in the entry.
623If there is no selection, it deletes the character to the left of
624the insertion cursor.
625
626=item [20]
627
628Control-d deletes the character to the right of the insertion cursor.
629
630=item [21]
631
632Meta-d deletes the word to the right of the insertion cursor.
633
634=item [22]
635
636Control-k deletes all the characters to the right of the insertion
637cursor.
638
639=item [23]
640
641Control-t reverses the order of the two characters to the right of
642the insertion cursor.
643
644If the entry is disabled using the B<-state> option, then the entry's
645view can still be adjusted and text in the entry can still be selected,
646but no insertion cursor will be displayed and no text modifications will
647take place.
648
649The behavior of entries can be changed by defining new bindings for
650individual widgets or by redefining the class bindings.
651
652=back
653
654=head1 KEYWORDS
655
656entry, widget
657
658=cut
659