624 lines
32 KiB
HTML
624 lines
32 KiB
HTML
|
<HTML><HEAD><TITLE>Tk Built-In Commands - entry manual page</TITLE></HEAD><BODY>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M2" NAME="L367">NAME</A>
|
||
|
<DL><DD>entry - Create and manipulate entry widgets</DL>
|
||
|
<DD><A HREF="entry.htm#M3" NAME="L368">SYNOPSIS</A>
|
||
|
<DL>
|
||
|
<DD><B>entry</B> <I>pathName </I>?<I>options</I>?
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M4" NAME="L369">STANDARD OPTIONS</A>
|
||
|
<DL>
|
||
|
<DD><A HREF="options.htm#M-background">-background or -bg, background, Background</A>
|
||
|
<DD><A HREF="options.htm#M-borderwidth">-borderwidth or -bd, borderWidth, BorderWidth</A>
|
||
|
<DD><A HREF="options.htm#M-cursor">-cursor, cursor, Cursor</A>
|
||
|
<DD><A HREF="options.htm#M-exportselection">-exportselection, exportSelection, ExportSelection</A>
|
||
|
<DD><A HREF="options.htm#M-font">-font, font, Font</A>
|
||
|
<DD><A HREF="options.htm#M-foreground">-foreground or -fg, foreground, Foreground</A>
|
||
|
<DD><A HREF="options.htm#M-highlightbackground">-highlightbackground, highlightBackground, HighlightBackground</A>
|
||
|
<DD><A HREF="options.htm#M-highlightcolor">-highlightcolor, highlightColor, HighlightColor</A>
|
||
|
<DD><A HREF="options.htm#M-highlightthickness">-highlightthickness, highlightThickness, HighlightThickness</A>
|
||
|
<DD><A HREF="options.htm#M-insertbackground">-insertbackground, insertBackground, Foreground</A>
|
||
|
<DD><A HREF="options.htm#M-insertborderwidth">-insertborderwidth, insertBorderWidth, BorderWidth</A>
|
||
|
<DD><A HREF="options.htm#M-insertofftime">-insertofftime, insertOffTime, OffTime</A>
|
||
|
<DD><A HREF="options.htm#M-insertontime">-insertontime, insertOnTime, OnTime</A>
|
||
|
<DD><A HREF="options.htm#M-insertwidth">-insertwidth, insertWidth, InsertWidth</A>
|
||
|
<DD><A HREF="options.htm#M-justify">-justify, justify, Justify</A>
|
||
|
<DD><A HREF="options.htm#M-relief">-relief, relief, Relief</A>
|
||
|
<DD><A HREF="options.htm#M-selectbackground">-selectbackground, selectBackground, Foreground</A>
|
||
|
<DD><A HREF="options.htm#M-selectborderwidth">-selectborderwidth, selectBorderWidth, BorderWidth</A>
|
||
|
<DD><A HREF="options.htm#M-selectforeground">-selectforeground, selectForeground, Background</A>
|
||
|
<DD><A HREF="options.htm#M-takefocus">-takefocus, takeFocus, TakeFocus</A>
|
||
|
<DD><A HREF="options.htm#M-textvariable">-textvariable, textVariable, Variable</A>
|
||
|
<DD><A HREF="options.htm#M-xscrollcommand">-xscrollcommand, xScrollCommand, ScrollCommand</A>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M5" NAME="L370">WIDGET-SPECIFIC OPTIONS</A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M6" NAME="L371">-invalidcommand or -invcmd, invalidCommand, InvalidCommand</A>
|
||
|
<DD><A HREF="entry.htm#M7" NAME="L372">-show, show, Show</A>
|
||
|
<DD><A HREF="entry.htm#M8" NAME="L373">-state, state, State</A>
|
||
|
<DD><A HREF="entry.htm#M9" NAME="L374">-validate, validate, Validate</A>
|
||
|
<DD><A HREF="entry.htm#M10" NAME="L375">-validatecommand or -vcmd, validateCommand, ValidateCommand</A>
|
||
|
<DD><A HREF="entry.htm#M11" NAME="L376">-width, width, Width</A>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M12" NAME="L377">DESCRIPTION</A>
|
||
|
<DD><A HREF="entry.htm#M13" NAME="L378">VALIDATION</A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M14" NAME="L379"><B>none</B></A>
|
||
|
<DD><A HREF="entry.htm#M15" NAME="L380"><B>focus</B></A>
|
||
|
<DD><A HREF="entry.htm#M16" NAME="L381"><B>focusin</B></A>
|
||
|
<DD><A HREF="entry.htm#M17" NAME="L382"><B>focusout</B></A>
|
||
|
<DD><A HREF="entry.htm#M18" NAME="L383"><B>key</B></A>
|
||
|
<DD><A HREF="entry.htm#M19" NAME="L384"><B>all</B></A>
|
||
|
</DL>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M20" NAME="L385"><B>%d</B></A>
|
||
|
<DD><A HREF="entry.htm#M21" NAME="L386"><B>%i</B></A>
|
||
|
<DD><A HREF="entry.htm#M22" NAME="L387"><B>%P</B></A>
|
||
|
<DD><A HREF="entry.htm#M23" NAME="L388"><B>%s</B></A>
|
||
|
<DD><A HREF="entry.htm#M24" NAME="L389"><B>%S</B></A>
|
||
|
<DD><A HREF="entry.htm#M25" NAME="L390"><B>%v</B></A>
|
||
|
<DD><A HREF="entry.htm#M26" NAME="L391"><B>%V</B></A>
|
||
|
<DD><A HREF="entry.htm#M27" NAME="L392"><B>%W</B></A>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M28" NAME="L393">WIDGET COMMAND</A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M29" NAME="L394"><I>number</I></A>
|
||
|
<DD><A HREF="entry.htm#M30" NAME="L395"><B>anchor</B></A>
|
||
|
<DD><A HREF="entry.htm#M31" NAME="L396"><B>end</B></A>
|
||
|
<DD><A HREF="entry.htm#M32" NAME="L397"><B>insert</B></A>
|
||
|
<DD><A HREF="entry.htm#M33" NAME="L398"><B>sel.first</B></A>
|
||
|
<DD><A HREF="entry.htm#M34" NAME="L399"><B>sel.last</B></A>
|
||
|
<DD><A HREF="entry.htm#M35" NAME="L400"><B>@</B><I>number</I></A>
|
||
|
</DL>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M36" NAME="L401"><I>pathName </I><B>bbox </B><I>index</I></A>
|
||
|
<DD><A HREF="entry.htm#M37" NAME="L402"><I>pathName </I><B>cget</B> <I>option</I></A>
|
||
|
<DD><A HREF="entry.htm#M38" NAME="L403"><I>pathName </I><B>configure</B> ?<I>option</I>? ?<I>value option value ...</I>?</A>
|
||
|
<DD><A HREF="entry.htm#M39" NAME="L404"><I>pathName </I><B>delete </B><I>first </I>?<I>last</I>?</A>
|
||
|
<DD><A HREF="entry.htm#M40" NAME="L405"><I>pathName </I><B>get</B></A>
|
||
|
<DD><A HREF="entry.htm#M41" NAME="L406"><I>pathName </I><B>icursor </B><I>index</I></A>
|
||
|
<DD><A HREF="entry.htm#M42" NAME="L407"><I>pathName </I><B>index</B><I> index</I></A>
|
||
|
<DD><A HREF="entry.htm#M43" NAME="L408"><I>pathName </I><B>insert </B><I>index string</I></A>
|
||
|
<DD><A HREF="entry.htm#M44" NAME="L409"><I>pathName </I><B>scan</B> <I>option args</I></A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M45" NAME="L410"><I>pathName </I><B>scan mark </B><I>x</I></A>
|
||
|
<DD><A HREF="entry.htm#M46" NAME="L411"><I>pathName </I><B>scan dragto </B><I>x</I></A>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M47" NAME="L412"><I>pathName </I><B>selection </B><I>option arg</I></A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M48" NAME="L413"><I>pathName </I><B>selection adjust </B><I>index</I></A>
|
||
|
<DD><A HREF="entry.htm#M49" NAME="L414"><I>pathName </I><B>selection clear</B></A>
|
||
|
<DD><A HREF="entry.htm#M50" NAME="L415"><I>pathName </I><B>selection from </B><I>index</I></A>
|
||
|
<DD><A HREF="entry.htm#M51" NAME="L416"><I>pathName </I><B>selection present</B></A>
|
||
|
<DD><A HREF="entry.htm#M52" NAME="L417"><I>pathName </I><B>selection range </B><I>start</I> <I>end</I></A>
|
||
|
<DD><A HREF="entry.htm#M53" NAME="L418"><I>pathName </I><B>selection to </B><I>index</I></A>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M54" NAME="L419">.VS 8.3</A>
|
||
|
<DD><A HREF="entry.htm#M55" NAME="L420"><I>pathName </I><B>xview </B><I>args</I></A>
|
||
|
<DL>
|
||
|
<DD><A HREF="entry.htm#M56" NAME="L421"><I>pathName </I><B>xview</B></A>
|
||
|
<DD><A HREF="entry.htm#M57" NAME="L422"><I>pathName </I><B>xview</B> <I>index</I></A>
|
||
|
<DD><A HREF="entry.htm#M58" NAME="L423"><I>pathName </I><B>xview moveto</B><I> fraction</I></A>
|
||
|
<DD><A HREF="entry.htm#M59" NAME="L424"><I>pathName </I><B>xview scroll </B><I>number what</I></A>
|
||
|
</DL>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M60" NAME="L425">DEFAULT BINDINGS</A>
|
||
|
<DL>
|
||
|
</DL>
|
||
|
<DD><A HREF="entry.htm#M61" NAME="L426">KEYWORDS</A>
|
||
|
</DL><HR>
|
||
|
<H3><A NAME="M2">NAME</A></H3>
|
||
|
entry - Create and manipulate entry widgets
|
||
|
<H3><A NAME="M3">SYNOPSIS</A></H3>
|
||
|
<B>entry</B> <I>pathName </I>?<I>options</I>?<BR>
|
||
|
<H3><A NAME="M4">STANDARD OPTIONS</A></H3>
|
||
|
<DL>
|
||
|
<DT><B><A HREF="options.htm#M-background">-background or -bg, background, Background</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-borderwidth">-borderwidth or -bd, borderWidth, BorderWidth</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-cursor">-cursor, cursor, Cursor</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-exportselection">-exportselection, exportSelection, ExportSelection</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-font">-font, font, Font</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-foreground">-foreground or -fg, foreground, Foreground</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-highlightbackground">-highlightbackground, highlightBackground, HighlightBackground</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-highlightcolor">-highlightcolor, highlightColor, HighlightColor</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-highlightthickness">-highlightthickness, highlightThickness, HighlightThickness</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-insertbackground">-insertbackground, insertBackground, Foreground</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-insertborderwidth">-insertborderwidth, insertBorderWidth, BorderWidth</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-insertofftime">-insertofftime, insertOffTime, OffTime</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-insertontime">-insertontime, insertOnTime, OnTime</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-insertwidth">-insertwidth, insertWidth, InsertWidth</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-justify">-justify, justify, Justify</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-relief">-relief, relief, Relief</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-selectbackground">-selectbackground, selectBackground, Foreground</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-selectborderwidth">-selectborderwidth, selectBorderWidth, BorderWidth</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-selectforeground">-selectforeground, selectForeground, Background</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-takefocus">-takefocus, takeFocus, TakeFocus</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-textvariable">-textvariable, textVariable, Variable</A></B>
|
||
|
<DT><B><A HREF="options.htm#M-xscrollcommand">-xscrollcommand, xScrollCommand, ScrollCommand</A></B>
|
||
|
</DL>
|
||
|
<H3><A NAME="M5">WIDGET-SPECIFIC OPTIONS</A></H3>
|
||
|
<DL>
|
||
|
<DT>Command-Line Name: <B><A NAME="M6">-invalidcommand or -invcmd</A></B>
|
||
|
<DT>Database Name: <B>invalidCommand</B>
|
||
|
<DT>Database Class: <B>InvalidCommand</B>
|
||
|
<DD>Specifies a script to eval when <B>validateCommand</B> returns 0.
|
||
|
Setting it to {} disables this feature (the default). The best use
|
||
|
of this option is to set it to <I>bell</I>. See <B>Validation</B>
|
||
|
below for more information.
|
||
|
<P><DT>Command-Line Name: <B><A NAME="M7">-show</A></B>
|
||
|
<DT>Database Name: <B>show</B>
|
||
|
<DT>Database Class: <B>Show</B>
|
||
|
<DD>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 ``*''.
|
||
|
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.
|
||
|
<P><DT>Command-Line Name: <B><A NAME="M8">-state</A></B>
|
||
|
<DT>Database Name: <B>state</B>
|
||
|
<DT>Database Class: <B>State</B>
|
||
|
<DD>Specifies one of two states for the entry: <B>normal</B> or <B>disabled</B>.
|
||
|
If the entry is disabled then the value may not be changed using widget
|
||
|
commands and no insertion cursor will be displayed, even if the input focus is
|
||
|
in the widget.
|
||
|
<P><DT>Command-Line Name: <B><A NAME="M9">-validate</A></B>
|
||
|
<DT>Database Name: <B>validate</B>
|
||
|
<DT>Database Class: <B>Validate</B>
|
||
|
<DD>Specifies the mode in which validation should operate: <B>none</B>,
|
||
|
<B><A HREF="../TclCmd/focus.htm">focus</A></B>, <B>focusin</B>, <B>focusout</B>, <B>key</B>, or <B>all</B>.
|
||
|
It defaults to <B>none</B>. When you want validation, you must explicitly
|
||
|
state which mode you wish to use. See <B>Validation</B> below for more.
|
||
|
<P><DT>Command-Line Name: <B><A NAME="M10">-validatecommand or -vcmd</A></B>
|
||
|
<DT>Database Name: <B>validateCommand</B>
|
||
|
<DT>Database Class: <B>ValidateCommand</B>
|
||
|
<DD>Specifies a script to eval when you want to validate the input into
|
||
|
the entry widget. Setting it to {} disables this feature (the default).
|
||
|
This command must return a valid tcl boolean value. If it returns 0 (or
|
||
|
the valid tcl boolean equivalent) then it means you reject the new edition
|
||
|
and it will not occur and the <B>invalidCommand</B> will be evaluated if it
|
||
|
is set. If it returns 1, then the new edition occurs.
|
||
|
See <B>Validation</B> below for more information.
|
||
|
<P><DT>Command-Line Name: <B><A NAME="M11">-width</A></B>
|
||
|
<DT>Database Name: <B>width</B>
|
||
|
<DT>Database Class: <B>Width</B>
|
||
|
<DD>Specifies an integer value indicating the desired width of the entry window,
|
||
|
in average-size characters of the widget's font.
|
||
|
If the value is less than or equal to zero, the widget picks a
|
||
|
size just large enough to hold its current text.
|
||
|
</DL>
|
||
|
<H3><A NAME="M12">DESCRIPTION</A></H3>
|
||
|
The <B>entry</B> command creates a new window (given by the
|
||
|
<I>pathName</I> argument) and makes it into an entry widget.
|
||
|
Additional options, described above, may be specified on the
|
||
|
command line or in the option database
|
||
|
to configure aspects of the entry such as its colors, font,
|
||
|
and relief. The <B>entry</B> command returns its
|
||
|
<I>pathName</I> argument. At the time this command is invoked,
|
||
|
there must not exist a window named <I>pathName</I>, but
|
||
|
<I>pathName</I>'s parent must exist.
|
||
|
<P>
|
||
|
An entry is a widget that displays a one-line text string and
|
||
|
allows that string to be edited using widget commands described below, which
|
||
|
are typically bound to keystrokes and mouse actions.
|
||
|
When first created, an entry's string is empty.
|
||
|
A portion of the entry may be selected as described below.
|
||
|
If an entry is exporting its selection (see the <B>exportSelection</B>
|
||
|
option), then it will observe the standard X11 protocols for handling the
|
||
|
selection; entry selections are available as type <B><A HREF="../TkCmd/string.htm">STRING</A></B>.
|
||
|
Entries also observe the standard Tk rules for dealing with the
|
||
|
input focus. When an entry has the input focus it displays an
|
||
|
<I>insertion cursor</I> to indicate where new characters will be
|
||
|
inserted.
|
||
|
<P>
|
||
|
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 <B>xScrollCommand</B> mechanism for interacting with
|
||
|
scrollbars (see the description of the <B>xScrollCommand</B> option
|
||
|
for details). They also support scanning, as described below.
|
||
|
|
||
|
<H3><A NAME="M13">VALIDATION</A></H3>
|
||
|
Validation works by setting the <B>validateCommand</B>
|
||
|
option to a script which will be evaluated according to the <B>validate</B>
|
||
|
option as follows:
|
||
|
<P>
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M14"><B>none</B></A><DD>
|
||
|
Default. This means no validation will occur.
|
||
|
<P><DT><A NAME="M15"><B>focus</B></A><DD>
|
||
|
<B>validateCommand</B> will be called when the entry receives or
|
||
|
loses focus.
|
||
|
<P><DT><A NAME="M16"><B>focusin</B></A><DD>
|
||
|
<B>validateCommand</B> will be called when the entry receives focus.
|
||
|
<P><DT><A NAME="M17"><B>focusout</B></A><DD>
|
||
|
<B>validateCommand</B> will be called when the entry loses focus.
|
||
|
<P><DT><A NAME="M18"><B>key</B></A><DD>
|
||
|
<B>validateCommand</B> will be called when the entry is edited.
|
||
|
<P><DT><A NAME="M19"><B>all</B></A><DD>
|
||
|
<B>validateCommand</B> will be called for all above conditions.
|
||
|
<P></DL>
|
||
|
<P>
|
||
|
It is posible to perform percent substitutions on the <B>validateCommand</B>
|
||
|
and <B>invalidCommand</B>,
|
||
|
just as you would in a <B><A HREF="../TclCmd/bind.htm">bind</A></B> script. The following substitutions
|
||
|
are recognized:
|
||
|
<P>
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M20"><B>%d</B></A><DD>
|
||
|
Type of action: 1 for <B>insert</B>, 0 for <B>delete</B>,
|
||
|
or -1 for focus, forced or textvariable validation.
|
||
|
<P><DT><A NAME="M21"><B>%i</B></A><DD>
|
||
|
Index of char string to be inserted/deleted, if any, otherwise -1.
|
||
|
<P><DT><A NAME="M22"><B>%P</B></A><DD>
|
||
|
The value of the entry should edition occur. If you are configuring the
|
||
|
entry widget to have a new textvariable, this will be the value of that
|
||
|
textvariable.
|
||
|
<P><DT><A NAME="M23"><B>%s</B></A><DD>
|
||
|
The current value of entry before edition.
|
||
|
<P><DT><A NAME="M24"><B>%S</B></A><DD>
|
||
|
The text string being inserted/deleted, if any, {} otherwise.
|
||
|
<P><DT><A NAME="M25"><B>%v</B></A><DD>
|
||
|
The type of validation currently set.
|
||
|
<P><DT><A NAME="M26"><B>%V</B></A><DD>
|
||
|
The type of validation that triggered the callback
|
||
|
(key, focusin, focusout, forced).
|
||
|
<P><DT><A NAME="M27"><B>%W</B></A><DD>
|
||
|
The name of the entry widget.
|
||
|
<P></DL>
|
||
|
<P>
|
||
|
In general, the <B>textVariable</B> and <B>validateCommand</B> can be
|
||
|
dangerous to mix. Any problems have been overcome so that using the
|
||
|
<B>validateCommand</B> will not interfere with the traditional behavior of
|
||
|
the entry widget. Using the <B>textVariable</B> for read-only purposes will
|
||
|
never cause problems. The danger comes when you try set the
|
||
|
<B>textVariable</B> to something that the <B>validateCommand</B> would not
|
||
|
accept, which causes <B>validate</B> to become <I>none</I> (the
|
||
|
<B>invalidCommand</B> will not be triggered). The same happens
|
||
|
when an error occurs evaluating the <B>validateCommand</B>.
|
||
|
<P>
|
||
|
Primarily, an error will occur when the <B>validateCommand</B> or
|
||
|
<B>invalidCommand</B> encounters an error in its script while evaluating or
|
||
|
<B>validateCommand</B> does not return a valid tcl boolean value. The
|
||
|
<B>validate</B> option will also set itself to <B>none</B> when you edit the
|
||
|
entry widget from within either the <B>validateCommand</B> or the
|
||
|
<B>invalidCommand</B>. Such editions will override the one that was being
|
||
|
validated. If you wish to edit the entry widget (for example set it to {})
|
||
|
during validation and still have the <B>validate</B> option set, you should
|
||
|
include the command
|
||
|
<PRE><I>after idle {%W config -validate %v}</I></PRE>
|
||
|
in the <B>validateCommand</B> or <B>invalidCommand</B> (whichever one you
|
||
|
were editing the entry widget from). It is also recommended to not set an
|
||
|
associated <B>textVariable</B> during validation, as that can cause the
|
||
|
entry widget to become out of sync with the <B>textVariable</B>.
|
||
|
|
||
|
<H3><A NAME="M28">WIDGET COMMAND</A></H3>
|
||
|
The <B>entry</B> command creates a new Tcl command whose
|
||
|
name is <I>pathName</I>. This command may be used to invoke various
|
||
|
operations on the widget. It has the following general form:
|
||
|
<PRE><I>pathName option </I>?<I>arg arg ...</I>?</PRE>
|
||
|
<I>Option</I> and the <I>arg</I>s
|
||
|
determine the exact behavior of the command.
|
||
|
<P>
|
||
|
Many of the widget commands for entries take one or more indices as
|
||
|
arguments. An index specifies a particular character in the entry's
|
||
|
string, in any of the following ways:
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M29"><I>number</I></A><DD>
|
||
|
Specifies the character as a numerical index, where 0 corresponds
|
||
|
to the first character in the string.
|
||
|
<P><DT><A NAME="M30"><B>anchor</B></A><DD>
|
||
|
Indicates the anchor point for the selection, which is set with the
|
||
|
<B>select from</B> and <B>select adjust</B> widget commands.
|
||
|
<P><DT><A NAME="M31"><B>end</B></A><DD>
|
||
|
Indicates the character just after the last one in the entry's string.
|
||
|
This is equivalent to specifying a numerical index equal to the length
|
||
|
of the entry's string.
|
||
|
<P><DT><A NAME="M32"><B>insert</B></A><DD>
|
||
|
Indicates the character adjacent to and immediately following the
|
||
|
insertion cursor.
|
||
|
<P><DT><A NAME="M33"><B>sel.first</B></A><DD>
|
||
|
Indicates the first character in the selection. It is an error to
|
||
|
use this form if the selection isn't in the entry window.
|
||
|
<P><DT><A NAME="M34"><B>sel.last</B></A><DD>
|
||
|
Indicates the character just after the last one in the selection.
|
||
|
It is an error to use this form if the selection isn't in the
|
||
|
entry window.
|
||
|
<P><DT><A NAME="M35"><B>@</B><I>number</I></A><DD>
|
||
|
In this form, <I>number</I> is treated as an x-coordinate in the
|
||
|
entry's window; the character spanning that x-coordinate is used.
|
||
|
For example, ``<B>@0</B>'' indicates the left-most character in the
|
||
|
window.
|
||
|
<P></DL>
|
||
|
<P>
|
||
|
Abbreviations may be used for any of the forms above, e.g. ``<B>e</B>''
|
||
|
or ``<B>sel.f</B>''. In general, out-of-range indices are automatically
|
||
|
rounded to the nearest legal value.
|
||
|
<P>
|
||
|
The following commands are possible for entry widgets:
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M36"><I>pathName </I><B>bbox </B><I>index</I></A><DD>
|
||
|
Returns a list of four numbers describing the bounding box of the
|
||
|
character given by <I>index</I>.
|
||
|
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.
|
||
|
<P><DT><A NAME="M37"><I>pathName </I><B>cget</B> <I>option</I></A><DD>
|
||
|
Returns the current value of the configuration option given
|
||
|
by <I>option</I>.
|
||
|
<I>Option</I> may have any of the values accepted by the <B>entry</B>
|
||
|
command.
|
||
|
<P><DT><A NAME="M38"><I>pathName </I><B>configure</B> ?<I>option</I>? ?<I>value option value ...</I>?</A><DD>
|
||
|
Query or modify the configuration options of the widget.
|
||
|
If no <I>option</I> is specified, returns a list describing all of
|
||
|
the available options for <I>pathName</I> (see <B><A HREF="../TclLib/ConfigWidg.htm">Tk_ConfigureInfo</A></B> for
|
||
|
information on the format of this list). If <I>option</I> is specified
|
||
|
with no <I>value</I>, then the command returns a list describing the
|
||
|
one named option (this list will be identical to the corresponding
|
||
|
sublist of the value returned if no <I>option</I> is specified). If
|
||
|
one or more <I>option-value</I> pairs are specified, then the command
|
||
|
modifies the given widget option(s) to have the given value(s); in
|
||
|
this case the command returns an empty string.
|
||
|
<I>Option</I> may have any of the values accepted by the <B>entry</B>
|
||
|
command.
|
||
|
<P><DT><A NAME="M39"><I>pathName </I><B>delete </B><I>first </I>?<I>last</I>?</A><DD>
|
||
|
Delete one or more elements of the entry.
|
||
|
<I>First</I> is the index of the first character to delete, and
|
||
|
<I>last</I> is the index of the character just after the last
|
||
|
one to delete.
|
||
|
If <I>last</I> isn't specified it defaults to <I>first</I>+1,
|
||
|
i.e. a single character is deleted.
|
||
|
This command returns an empty string.
|
||
|
<P><DT><A NAME="M40"><I>pathName </I><B>get</B></A><DD>
|
||
|
Returns the entry's string.
|
||
|
<P><DT><A NAME="M41"><I>pathName </I><B>icursor </B><I>index</I></A><DD>
|
||
|
Arrange for the insertion cursor to be displayed just before the character
|
||
|
given by <I>index</I>. Returns an empty string.
|
||
|
<P><DT><A NAME="M42"><I>pathName </I><B>index</B><I> index</I></A><DD>
|
||
|
Returns the numerical index corresponding to <I>index</I>.
|
||
|
<P><DT><A NAME="M43"><I>pathName </I><B>insert </B><I>index string</I></A><DD>
|
||
|
Insert the characters of <I>string</I> just before the character
|
||
|
indicated by <I>index</I>. Returns an empty string.
|
||
|
<P><DT><A NAME="M44"><I>pathName </I><B>scan</B> <I>option args</I></A><DD>
|
||
|
This command is used to implement scanning on entries. It has
|
||
|
two forms, depending on <I>option</I>:
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M45"><I>pathName </I><B>scan mark </B><I>x</I></A><DD>
|
||
|
Records <I>x</I> and the current view in the entry window; used in
|
||
|
conjunction with later <B>scan dragto</B> commands. Typically this
|
||
|
command is associated with a mouse button press in the widget. It
|
||
|
returns an empty string.
|
||
|
<P><DT><A NAME="M46"><I>pathName </I><B>scan dragto </B><I>x</I></A><DD>
|
||
|
This command computes the difference between its <I>x</I> argument
|
||
|
and the <I>x</I> argument to the last <B>scan mark</B> command for
|
||
|
the widget. It then adjusts the view left or right by 10 times the
|
||
|
difference in x-coordinates. This command is typically associated
|
||
|
with mouse motion events in the widget, to produce the effect of
|
||
|
dragging the entry at high speed through the window. The return
|
||
|
value is an empty string.
|
||
|
<P></DL>
|
||
|
<P><DT><A NAME="M47"><I>pathName </I><B>selection </B><I>option arg</I></A><DD>
|
||
|
This command is used to adjust the selection within an entry. It
|
||
|
has several forms, depending on <I>option</I>:
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M48"><I>pathName </I><B>selection adjust </B><I>index</I></A><DD>
|
||
|
Locate the end of the selection nearest to the character given by
|
||
|
<I>index</I>, and adjust that end of the selection to be at <I>index</I>
|
||
|
(i.e including but not going beyond <I>index</I>). The other
|
||
|
end of the selection is made the anchor point for future
|
||
|
<B>select to</B> commands. If the selection
|
||
|
isn't currently in the entry, then a new selection is created to
|
||
|
include the characters between <I>index</I> and the most recent
|
||
|
selection anchor point, inclusive.
|
||
|
Returns an empty string.
|
||
|
<P><DT><A NAME="M49"><I>pathName </I><B>selection clear</B></A><DD>
|
||
|
Clear the selection if it is currently in this widget. If the
|
||
|
selection isn't in this widget then the command has no effect.
|
||
|
Returns an empty string.
|
||
|
<P><DT><A NAME="M50"><I>pathName </I><B>selection from </B><I>index</I></A><DD>
|
||
|
Set the selection anchor point to just before the character
|
||
|
given by <I>index</I>. Doesn't change the selection.
|
||
|
Returns an empty string.
|
||
|
<P><DT><A NAME="M51"><I>pathName </I><B>selection present</B></A><DD>
|
||
|
Returns 1 if there is are characters selected in the entry,
|
||
|
0 if nothing is selected.
|
||
|
<P><DT><A NAME="M52"><I>pathName </I><B>selection range </B><I>start</I> <I>end</I></A><DD>
|
||
|
Sets the selection to include the characters starting with
|
||
|
the one indexed by <I>start</I> and ending with the one just
|
||
|
before <I>end</I>.
|
||
|
If <I>end</I> refers to the same character as <I>start</I> or an
|
||
|
earlier one, then the entry's selection is cleared.
|
||
|
<P><DT><A NAME="M53"><I>pathName </I><B>selection to </B><I>index</I></A><DD>
|
||
|
If <I>index</I> is before the anchor point, set the selection
|
||
|
to the characters from <I>index</I> up to but not including
|
||
|
the anchor point.
|
||
|
If <I>index</I> is the same as the anchor point, do nothing.
|
||
|
If <I>index</I> is after the anchor point, set the selection
|
||
|
to the characters from the anchor point up to but not including
|
||
|
<I>index</I>.
|
||
|
The anchor point is determined by the most recent <B>select from</B>
|
||
|
or <B>select adjust</B> command in this widget.
|
||
|
If the selection isn't in this widget then a new selection is
|
||
|
created using the most recent anchor point specified for the widget.
|
||
|
Returns an empty string.
|
||
|
<P></DL>
|
||
|
<P><DT><A NAME="M54">.VS 8.3</A><DD>
|
||
|
<I>pathName </I><B>validate</B>
|
||
|
This command is used to force an evaluation of the <B>validateCommand</B>
|
||
|
independent of the conditions specified by the <B>validate</B> option.
|
||
|
This is done by temporarily setting the <B>validate</B> option to <B>all</B>.
|
||
|
It returns 0 or 1.
|
||
|
<P><DT><A NAME="M55"><I>pathName </I><B>xview </B><I>args</I></A><DD>
|
||
|
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:
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT><A NAME="M56"><I>pathName </I><B>xview</B></A><DD>
|
||
|
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 <B>-xscrollcommand</B>
|
||
|
option.
|
||
|
<P><DT><A NAME="M57"><I>pathName </I><B>xview</B> <I>index</I></A><DD>
|
||
|
Adjusts the view in the window so that the character given by <I>index</I>
|
||
|
is displayed at the left edge of the window.
|
||
|
<P><DT><A NAME="M58"><I>pathName </I><B>xview moveto</B><I> fraction</I></A><DD>
|
||
|
Adjusts the view in the window so that the character <I>fraction</I> of the
|
||
|
way through the text appears at the left edge of the window.
|
||
|
<I>Fraction</I> must be a fraction between 0 and 1.
|
||
|
<P><DT><A NAME="M59"><I>pathName </I><B>xview scroll </B><I>number what</I></A><DD>
|
||
|
This command shifts the view in the window left or right according to
|
||
|
<I>number</I> and <I>what</I>.
|
||
|
<I>Number</I> must be an integer.
|
||
|
<I>What</I> must be either <B>units</B> or <B>pages</B> or an abbreviation
|
||
|
of one of these.
|
||
|
If <I>what</I> is <B>units</B>, the view adjusts left or right by
|
||
|
<I>number</I> average-width characters on the display; if it is
|
||
|
<B>pages</B> then the view adjusts by <I>number</I> screenfuls.
|
||
|
If <I>number</I> is negative then characters farther to the left
|
||
|
become visible; if it is positive then characters farther to the right
|
||
|
become visible.
|
||
|
<P></DL>
|
||
|
<P></DL>
|
||
|
<H3><A NAME="M60">DEFAULT BINDINGS</A></H3>
|
||
|
Tk automatically creates class bindings for entries that give them
|
||
|
the following default behavior.
|
||
|
In the descriptions below, ``word'' refers to a contiguous group
|
||
|
of letters, digits, or ``_'' characters, or any single character
|
||
|
other than these.
|
||
|
<P>
|
||
|
<DL>
|
||
|
<P><DT>[1]<DD>
|
||
|
Clicking mouse button 1 positions the insertion cursor
|
||
|
just before the character underneath the mouse cursor, sets the
|
||
|
input focus to this widget, and clears any selection in the widget.
|
||
|
Dragging with mouse button 1 strokes out a selection between
|
||
|
the insertion cursor and the character under the mouse.
|
||
|
<P><DT>[2]<DD>
|
||
|
Double-clicking with mouse button 1 selects the word under the mouse
|
||
|
and positions the insertion cursor at the beginning of the word.
|
||
|
Dragging after a double click will stroke out a selection consisting
|
||
|
of whole words.
|
||
|
<P><DT>[3]<DD>
|
||
|
Triple-clicking with mouse button 1 selects all of the text in the
|
||
|
entry and positions the insertion cursor before the first character.
|
||
|
<P><DT>[4]<DD>
|
||
|
The ends of the selection can be adjusted by dragging with mouse
|
||
|
button 1 while the Shift key is down; this will adjust the end
|
||
|
of the selection that was nearest to the mouse cursor when button
|
||
|
1 was pressed.
|
||
|
If the button is double-clicked before dragging then the selection
|
||
|
will be adjusted in units of whole words.
|
||
|
<P><DT>[5]<DD>
|
||
|
Clicking mouse button 1 with the Control key down will position the
|
||
|
insertion cursor in the entry without affecting the selection.
|
||
|
<P><DT>[6]<DD>
|
||
|
If any normal printing characters are typed in an entry, they are
|
||
|
inserted at the point of the insertion cursor.
|
||
|
<P><DT>[7]<DD>
|
||
|
The view in the entry can be adjusted by dragging with mouse button 2.
|
||
|
If mouse button 2 is clicked without moving the mouse, the selection
|
||
|
is copied into the entry at the position of the mouse cursor.
|
||
|
<P><DT>[8]<DD>
|
||
|
If the mouse is dragged out of the entry on the left or right sides
|
||
|
while button 1 is pressed, the entry will automatically scroll to
|
||
|
make more text visible (if there is more text off-screen on the side
|
||
|
where the mouse left the window).
|
||
|
<P><DT>[9]<DD>
|
||
|
The Left and Right keys move the insertion cursor one character to the
|
||
|
left or right; they also clear any selection in the entry and set
|
||
|
the selection anchor.
|
||
|
If Left or Right is typed with the Shift key down, then the insertion
|
||
|
cursor moves and the selection is extended to include the new character.
|
||
|
Control-Left and Control-Right move the insertion cursor by words, and
|
||
|
Control-Shift-Left and Control-Shift-Right move the insertion cursor
|
||
|
by words and also extend the selection.
|
||
|
Control-b and Control-f behave the same as Left and Right, respectively.
|
||
|
Meta-b and Meta-f behave the same as Control-Left and Control-Right,
|
||
|
respectively.
|
||
|
<P><DT>[10]<DD>
|
||
|
The Home key, or Control-a, will move the insertion cursor to the
|
||
|
beginning of the entry and clear any selection in the entry.
|
||
|
Shift-Home moves the insertion cursor to the beginning of the entry
|
||
|
and also extends the selection to that point.
|
||
|
<P><DT>[11]<DD>
|
||
|
The End key, or Control-e, will move the insertion cursor to the
|
||
|
end of the entry and clear any selection in the entry.
|
||
|
Shift-End moves the cursor to the end and extends the selection
|
||
|
to that point.
|
||
|
<P><DT>[12]<DD>
|
||
|
The Select key and Control-Space set the selection anchor to the position
|
||
|
of the insertion cursor. They don't affect the current selection.
|
||
|
Shift-Select and Control-Shift-Space adjust the selection to the
|
||
|
current position of the insertion cursor, selecting from the anchor
|
||
|
to the insertion cursor if there was not any selection previously.
|
||
|
<P><DT>[13]<DD>
|
||
|
Control-/ selects all the text in the entry.
|
||
|
<P><DT>[14]<DD>
|
||
|
Control-\ clears any selection in the entry.
|
||
|
<P><DT>[15]<DD>
|
||
|
The F16 key (labelled Copy on many Sun workstations) or Meta-w
|
||
|
copies the selection in the widget to the clipboard, if there is a selection.
|
||
|
<P><DT>[16]<DD>
|
||
|
The F20 key (labelled Cut on many Sun workstations) or Control-w
|
||
|
copies the selection in the widget to the clipboard and deletes
|
||
|
the selection.
|
||
|
If there is no selection in the widget then these keys have no effect.
|
||
|
<P><DT>[17]<DD>
|
||
|
The F18 key (labelled Paste on many Sun workstations) or Control-y
|
||
|
inserts the contents of the clipboard at the position of the
|
||
|
insertion cursor.
|
||
|
<P><DT>[18]<DD>
|
||
|
The Delete key deletes the selection, if there is one in the entry.
|
||
|
If there is no selection, it deletes the character to the right of
|
||
|
the insertion cursor.
|
||
|
<P><DT>[19]<DD>
|
||
|
The BackSpace key and Control-h delete the selection, if there is one
|
||
|
in the entry.
|
||
|
If there is no selection, it deletes the character to the left of
|
||
|
the insertion cursor.
|
||
|
<P><DT>[20]<DD>
|
||
|
Control-d deletes the character to the right of the insertion cursor.
|
||
|
<P><DT>[21]<DD>
|
||
|
Meta-d deletes the word to the right of the insertion cursor.
|
||
|
<P><DT>[22]<DD>
|
||
|
Control-k deletes all the characters to the right of the insertion
|
||
|
cursor.
|
||
|
<P><DT>[23]<DD>
|
||
|
Control-t reverses the order of the two characters to the right of
|
||
|
the insertion cursor.
|
||
|
<P></DL>
|
||
|
<P>
|
||
|
If the entry is disabled using the <B>-state</B> option, then the entry's
|
||
|
view can still be adjusted and text in the entry can still be selected,
|
||
|
but no insertion cursor will be displayed and no text modifications will
|
||
|
take place.
|
||
|
<P>
|
||
|
The behavior of entries can be changed by defining new bindings for
|
||
|
individual widgets or by redefining the class bindings.
|
||
|
|
||
|
<H3><A NAME="M61">KEYWORDS</A></H3>
|
||
|
<A href="../Keywords/E.htm#entry">entry</A>, <A href="../Keywords/W.htm#widget">widget</A>
|
||
|
<HR><PRE>
|
||
|
<A HREF="../copyright.htm">Copyright</A> © 1990-1994 The Regents of the University of California.
|
||
|
<A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc.
|
||
|
<A HREF="../copyright.htm">Copyright</A> © 1998-2000 Scriptics Corporation.
|
||
|
<A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE>
|
||
|
</BODY></HTML>
|