Copyright (c) 1994-1996 Sun Microsystems, Inc.
Copyright (c) 1998-2000 Scriptics Corporation.
Copyright (c) 2004 Joe English
See the file "license.terms" for information on usage and redistribution
of this file, and for a DISCLAIMER OF ALL WARRANTIES.
SOURCE: entry.n, r1.12
RCS: @(#) $Id$
.so man.macros
An ttk::entry widget displays a one-line text string and allows that string to be edited by the user. The value of the string may be linked to a Tcl variable with the -textvariable option. Entry widgets support horizontal scrolling with the standard -xscrollcommand option and xview widget command. .SO ttk_widget -class -cursor -style -takefocus -xscrollcommand .SE
MAYBE: .OP -foreground foreground Foreground
MAYBE: .OP -insertbackground insertBackground Foreground
MAYBE: .OP -insertwidth insertWidth InsertWidth
.OP -invalidcommand invalidCommand InvalidCommand A script template to evaluate whenever the validateCommand returns 0. See VALIDATION below for more information. .OP -justify justify Justify Specifies how the text is aligned within the entry widget. One of left, center, or right. MAYBE: .OP -selectbackground selectBackground Foreground
MAYBE: .OP -selectborderwidth selectBorderWidth BorderWidth
MAYBE: .OP -selectforeground selectForeground Background
.OP -show show Show If this option is specified, then the true contents of the entry are not displayed in the window. Instead, each character in the entry's value will be displayed as the first character in the value of this option, such as .QW * or a bullet. This is useful, for example, if the entry is to be used to enter a password. If characters in the entry are selected and copied elsewhere, the information copied will be what is displayed, not the true contents of the entry. .OP -state state State Compatibility option; see ttk::widget(n) for details. Specifies one of three states for the entry, normal, disabled, or readonly. See WIDGET STATES, below. .OP -textvariable textVariable Variable Specifies the name of a variable whose value is linked to the entry widget's contents. Whenever the variable changes value, the widget's contents are updated, and vice versa. .OP -validate validate Validate Specifies the mode in which validation should operate: none, focus, focusin, focusout, key, or all. Default is none, meaning that validation is disabled. See VALIDATION below. .OP -validatecommand validateCommand ValidateCommand A script template to evaluate whenever validation is triggered. If set to the empty string (the default), validation is disabled. The script must return a boolean value. See VALIDATION below. .OP -width width Width Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget's font. Not in ttk: If the value is less than or equal to zero, the widget picks a
Not in ttk: size just large enough to hold its current text.
A portion of the entry may be selected as described below. If an entry is exporting its selection (see the exportSelection option), then it will observe the standard X11 protocols for handling the selection; entry selections are available as type STRING. Entries also observe the standard Tk rules for dealing with the input focus. When an entry has the input focus it displays an insert cursor to indicate where new characters will be inserted.
Entries are capable of displaying strings that are too long to fit entirely within the widget's window. In this case, only a portion of the string will be displayed; commands described below may be used to change the view in the window. Entries use the standard xScrollCommand mechanism for interacting with scrollbars (see the description of the xScrollCommand option for details).
Many of the entry widget commands take one or more indices as arguments. An index specifies a particular character in the entry's string, in any of the following ways:
Abbreviations may be used for any of the forms above, e.g.\| .QW e or .QW sel.l . In general, out-of-range indices are automatically rounded to the nearest legal value.
The following subcommands are possible for entry widgets:
pathName bbox index
Returns a list of four numbers describing the bounding box of the
character given by index.
The first two elements of the list give the x and y coordinates of
the upper-left corner of the screen area covered by the character
(in pixels relative to the widget) and the last two elements give
the width and height of the character, in pixels.
The bounding box may refer to a region outside the visible area
of the window.
.TP
pathName cget option
Returns the current value of the specified option.
See ttk::widget(n).
.TP
pathName configure ?option? ?value option value ...?
Modify or query widget options.
See ttk::widget(n).
pathName delete first ?last? Delete one or more elements of the entry. First is the index of the first character to delete, and last is the index of the character just after the last one to delete. If last is not specified it defaults to first+1, i.e. a single character is deleted. This command returns the empty string.
pathName get Returns the entry's string.
pathName icursor index
Arrange for the insert cursor to be displayed just before the character
given by index. Returns the empty string.
.TP
pathName identify x y
Returns the name of the element at position x, y,
or the empty string if the coordinates are outside the window.
pathName index index Returns the numerical index corresponding to index.
pathName insert index string
Insert string just before the character
indicated by index. Returns the empty string.
.TP
pathName instate statespec ?script?
Test the widget state.
See ttk::widget(n).
pathName selection option arg This command is used to adjust the selection within an entry. It has several forms, depending on option:
pathName selection clear Clear the selection if it is currently in this widget. If the selection is not in this widget then the command has no effect. Returns the empty string.
pathName selection present Returns 1 if there is are characters selected in the entry, 0 if nothing is selected.
pathName selection range start end Sets the selection to include the characters starting with the one indexed by start and ending with the one just before end. If end refers to the same character as start or an earlier one, then the entry's selection is cleared.
pathName state ?stateSpec?
Modify or query the widget state.
See ttk::widget(n).
pathName validate Force revalidation, independent of the conditions specified by the -validate option. Returns 0 if validation fails, 1 if it succeeds. Sets or clears the invalid state accordingly. See VALIDATION below for more details.
pathName xview args This command is used to query and change the horizontal position of the text in the widget's window. It can take any of the following forms:
pathName xview Returns a list containing two elements. Each element is a real fraction between 0 and 1; together they describe the horizontal span that is visible in the window. For example, if the first element is .2 and the second element is .6, 20% of the entry's text is off-screen to the left, the middle 40% is visible in the window, and 40% of the text is off-screen to the right. These are the same values passed to scrollbars via the -xscrollcommand option.
pathName xview index Adjusts the view in the window so that the character given by index is displayed at the left edge of the window.
pathName xview moveto fraction Adjusts the view in the window so that the character fraction of the way through the text appears at the left edge of the window. Fraction must be a fraction between 0 and 1.
pathName xview scroll number what
This command shifts the view in the window left or right according to
number and what.
Number must be an integer.
What must be either units or pages.
or an abbreviation of one of these, but we don't document that.
If what is units, the view adjusts left or right by
number average-width characters on the display; if it is
pages then the view adjusts by number screenfuls.
If number is negative then characters farther to the left
become visible; if it is positive then characters farther to the right
become visible.
The entry widget also supports the following generic ttk::widget widget subcommands (see ttk::widget(n) for details): cget configure identify instate state
The -validate, -validatecommand, and -invalidcommand options are used to enable entry widget validation.
There are two main validation modes: prevalidation, in which the -validatecommand is evaluated prior to each edit and the return value is used to determine whether to accept or reject the change; and revalidation, in which the -validatecommand is evaluated to determine whether the current value is valid.
The -validate option determines when validation occurs; it may be set to any of the following values:
The -invalidcommand is evaluated whenever the -validatecommand returns a false value.
The -validatecommand and -invalidcommand may modify the entry widget's value via the widget insert or delete commands, or by setting the linked -textvariable. If either does so during prevalidation, then the edit is rejected regardless of the value returned by the -validatecommand.
If -validatecommand is empty (the default), validation always succeeds.
It is possible to perform percent substitutions on the -validatecommand and -invalidcommand, just as in a bind script. The following substitutions are recognized:
The standard Tk entry widget automatically disables validation (by setting -validate to none) if the -validatecommand or -invalidcommand modifies the entry's value. The Tk themed entry widget only disables validation if one of the validation scripts raises an error, or if -validatecommand does not return a valid boolean value. (Thus, it is not necessary to re-enable validation after modifying the entry value in a validation script).
In addition, the standard entry widget invokes validation whenever the linked -textvariable is modified; the Tk themed entry widget does not.
The entry widget's default bindings enable the following behavior. In the descriptions below, .QW word refers to a contiguous group of letters, digits, or .QW _ characters, or any single character other than these.
In the disabled state, the entry cannot be edited and the text cannot be selected. In the readonly state, no insert cursor is displayed and the entry cannot be edited (specifically: the insert and delete commands have no effect). The disabled state is the same as readonly, and in addition text cannot be selected.
Note that changes to the linked -textvariable will still be reflected in the entry, even if it is disabled or readonly.
Typically, the text is .QW grayed-out in the disabled state, and a different background is used in the readonly state.
The entry widget sets the invalid state if revalidation fails, and clears it whenever validation succeeds.
mode: nroff
End: