| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html> |
| 3 |
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ --> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>entry (GCL TK Manual)</title> |
| 7 |
|
| 8 |
<meta name="description" content="entry (GCL TK Manual)"> |
| 9 |
<meta name="keywords" content="entry (GCL TK Manual)"> |
| 10 |
<meta name="resource-type" content="document"> |
| 11 |
<meta name="distribution" content="global"> |
| 12 |
<meta name="Generator" content="makeinfo"> |
| 13 |
<link href="index.html" rel="start" title="Top"> |
| 14 |
<link href="wm.html#SEC_Contents" rel="contents" title="Table of Contents"> |
| 15 |
<link href="Widgets.html" rel="up" title="Widgets"> |
| 16 |
<link href="message.html" rel="next" title="message"> |
| 17 |
<link href="text.html" rel="prev" title="text"> |
| 18 |
<style type="text/css"> |
| 19 |
<!-- |
| 20 |
a.summary-letter {text-decoration: none} |
| 21 |
blockquote.indentedblock {margin-right: 0em} |
| 22 |
div.display {margin-left: 3.2em} |
| 23 |
div.example {margin-left: 3.2em} |
| 24 |
div.lisp {margin-left: 3.2em} |
| 25 |
kbd {font-style: oblique} |
| 26 |
pre.display {font-family: inherit} |
| 27 |
pre.format {font-family: inherit} |
| 28 |
pre.menu-comment {font-family: serif} |
| 29 |
pre.menu-preformatted {font-family: serif} |
| 30 |
span.nolinebreak {white-space: nowrap} |
| 31 |
span.roman {font-family: initial; font-weight: normal} |
| 32 |
span.sansserif {font-family: sans-serif; font-weight: normal} |
| 33 |
ul.no-bullet {list-style: none} |
| 34 |
--> |
| 35 |
</style> |
| 36 |
|
| 37 |
|
| 38 |
</head> |
| 39 |
|
| 40 |
<body lang="en"> |
| 41 |
<span id="entry"></span><div class="header"> |
| 42 |
<p> |
| 43 |
Next: <a href="message.html" accesskey="n" rel="next">message</a>, Previous: <a href="text.html" accesskey="p" rel="prev">text</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> |
| 44 |
</div> |
| 45 |
<hr> |
| 46 |
<span id="entry-1"></span><h3 class="section">2.10 entry</h3> |
| 47 |
|
| 48 |
<p>entry \- Create and manipulate entry widgets |
| 49 |
</p><span id="Synopsis-9"></span><h4 class="unnumberedsubsec">Synopsis</h4> |
| 50 |
<p><b>entry</b><i> </i><i>pathName </i><span class="roman">?</span><i>options</i>? |
| 51 |
</p><span id="Standard-Options-9"></span><h4 class="unnumberedsubsec">Standard Options</h4> |
| 52 |
|
| 53 |
|
| 54 |
<div class="example"> |
| 55 |
<pre class="example">background foreground insertWidth selectForeground |
| 56 |
borderWidth insertBackground relief textVariable |
| 57 |
cursor insertBorderWidth scrollCommand |
| 58 |
exportSelection insertOffTime selectBackground |
| 59 |
font insertOnTime selectBorderWidth |
| 60 |
</pre></div> |
| 61 |
|
| 62 |
|
| 63 |
<p>See <a href="options.html">options</a>, for more information. |
| 64 |
</p><span id="Arguments-for-Entry"></span><h4 class="unnumberedsubsec">Arguments for Entry</h4> |
| 65 |
|
| 66 |
|
| 67 |
<dl compact="compact"> |
| 68 |
<dt><code><b>:state</b></code></dt> |
| 69 |
<dd><p align="right">Name=<code>"<b>state</b><span class="roman">"</span> Class=<code>"</code><b>State</b>"</code> |
| 70 |
</p><br> |
| 71 |
|
| 72 |
<p>Specifies one of two states for the entry: <b>normal</b><span class="roman"> or </span><b>disabled</b>. |
| 73 |
If the entry is disabled then the value may not be changed using widget |
| 74 |
commands and no insertion cursor will be displayed, even if the input focus is |
| 75 |
in the widget. |
| 76 |
</p></dd> |
| 77 |
</dl> |
| 78 |
|
| 79 |
|
| 80 |
<dl compact="compact"> |
| 81 |
<dt><code><b>:width</b></code></dt> |
| 82 |
<dd><p align="right">Name=<code>"<b>width</b><span class="roman">"</span> Class=<code>"</code><b>Width</b>"</code> |
| 83 |
</p><br> |
| 84 |
|
| 85 |
<p>Specifies an integer value indicating the desired width of the entry window, |
| 86 |
in average-size characters of the widget’s font. |
| 87 |
</p></dd> |
| 88 |
</dl> |
| 89 |
|
| 90 |
<span id="Description-6"></span><h4 class="unnumberedsubsec">Description</h4> |
| 91 |
|
| 92 |
<p>The <b>entry</b> command creates a new window (given by the |
| 93 |
<i>pathName</i> argument) and makes it into an entry widget. |
| 94 |
Additional options, described above, may be specified on the |
| 95 |
command line or in the option database |
| 96 |
to configure aspects of the entry such as its colors, font, |
| 97 |
and relief. The <b>entry</b> command returns its |
| 98 |
<i>pathName</i> argument. At the time this command is invoked, |
| 99 |
there must not exist a window named <i>pathName</i>, but |
| 100 |
<i>pathName</i>’s parent must exist. |
| 101 |
</p> |
| 102 |
<p>An entry is a widget that displays a one-line text string and |
| 103 |
allows that string to be edited using widget commands described below, which |
| 104 |
are typically bound to keystrokes and mouse actions. |
| 105 |
When first created, an entry’s string is empty. |
| 106 |
A portion of the entry may be selected as described below. |
| 107 |
If an entry is exporting its selection (see the <b>exportSelection</b> |
| 108 |
option), then it will observe the standard X11 protocols for handling the |
| 109 |
selection; entry selections are available as type <b>STRING</b>. |
| 110 |
Entries also observe the standard Tk rules for dealing with the |
| 111 |
input focus. When an entry has the input focus it displays an |
| 112 |
<i>insertion cursor</i> to indicate where new characters will be |
| 113 |
inserted. |
| 114 |
</p> |
| 115 |
<p>Entries are capable of displaying strings that are too long to |
| 116 |
fit entirely within the widget’s window. In this case, only a |
| 117 |
portion of the string will be displayed; commands described below |
| 118 |
may be used to change the view in the window. Entries use |
| 119 |
the standard <b>scrollCommand</b> mechanism for interacting with |
| 120 |
scrollbars (see the description of the <b>scrollCommand</b> option |
| 121 |
for details). They also support scanning, as described below. |
| 122 |
</p> |
| 123 |
<span id="A-Entry-Widget_0027s-Arguments"></span><h4 class="unnumberedsubsec">A Entry Widget’s Arguments</h4> |
| 124 |
|
| 125 |
<p>The <b>entry</b> command creates a new Tcl command whose |
| 126 |
name is <i>pathName</i>. This |
| 127 |
command may be used to invoke various |
| 128 |
operations on the widget. It has the following general form: |
| 129 |
</p> |
| 130 |
<div class="example"> |
| 131 |
<pre class="example"><i>pathName option </i><span class="roman">?</span><i>arg arg ...</i>? |
| 132 |
</pre></div> |
| 133 |
|
| 134 |
<p><i>Option</i><span class="roman"> and the </span><i>arg</i>s |
| 135 |
determine the exact behavior of the command. |
| 136 |
</p> |
| 137 |
<p>Many of the widget commands for entries take one or more indices as |
| 138 |
arguments. An index specifies a particular character in the entry’s |
| 139 |
string, in any of the following ways: |
| 140 |
</p> |
| 141 |
<dl compact="compact"> |
| 142 |
<dt><i>number</i></dt> |
| 143 |
<dd><p>Specifies the character as a numerical index, where 0 corresponds |
| 144 |
to the first character in the string. |
| 145 |
</p></dd> |
| 146 |
<dt><b>end</b></dt> |
| 147 |
<dd><p>Indicates the character just after the last one in the entry’s string. |
| 148 |
This is equivalent to specifying a numerical index equal to the length |
| 149 |
of the entry’s string. |
| 150 |
</p></dd> |
| 151 |
<dt><b>insert</b></dt> |
| 152 |
<dd><p>Indicates the character adjacent to and immediately following the |
| 153 |
insertion cursor. |
| 154 |
</p></dd> |
| 155 |
<dt><b>sel.first</b></dt> |
| 156 |
<dd><p>Indicates the first character in the selection. It is an error to |
| 157 |
use this form if the selection isn’t in the entry window. |
| 158 |
</p></dd> |
| 159 |
<dt><b>sel.last</b></dt> |
| 160 |
<dd><p>Indicates the last character in the selection. It is an error to |
| 161 |
use this form if the selection isn’t in the entry window. |
| 162 |
</p></dd> |
| 163 |
<dt><b>@</b><i>number</i></dt> |
| 164 |
<dd><p>In this form, <i>number</i> is treated as an x-coordinate in the |
| 165 |
entry’s window; the character spanning that x-coordinate is used. |
| 166 |
For example, “<b>@0</b>” indicates the left-most character in the |
| 167 |
window. |
| 168 |
</p></dd> |
| 169 |
</dl> |
| 170 |
|
| 171 |
|
| 172 |
<p>Abbreviations may be used for any of the forms above, e.g. “<b>e</b>” |
| 173 |
or “<b>sel.f</b>”. In general, out-of-range indices are automatically |
| 174 |
rounded to the nearest legal value. |
| 175 |
</p> |
| 176 |
<p>The following commands are possible for entry widgets: |
| 177 |
</p> |
| 178 |
<dl compact="compact"> |
| 179 |
<dt><i>pathName </i><b>:configure</b><span class="roman"> ?</span><i>option</i><span class="roman">? ?</span><i>value option value ...</i>?</dt> |
| 180 |
<dd><p>Query or modify the configuration options of the widget. |
| 181 |
If no <i>option</i> is specified, returns a list describing all of |
| 182 |
the available options for <i>pathName</i><span class="roman"> (see </span><b>Tk_ConfigureInfo</b> for |
| 183 |
information on the format of this list). If <i>option</i> is specified |
| 184 |
with no <i>value</i>, then the command returns a list describing the |
| 185 |
one named option (this list will be identical to the corresponding |
| 186 |
sublist of the value returned if no <i>option</i> is specified). If |
| 187 |
one or more <i>option:value</i> pairs are specified, then the command |
| 188 |
modifies the given widget option(s) to have the given value(s); in |
| 189 |
this case the command returns an empty string. |
| 190 |
<i>Option</i><span class="roman"> may have any of the values accepted by the </span><b>entry</b> |
| 191 |
command. |
| 192 |
</p></dd> |
| 193 |
<dt><i>pathName </i><b>:delete </b><i>first </i><span class="roman">?</span><i>last</i>?</dt> |
| 194 |
<dd><p>Delete one or more elements of the entry. <i>First</i><span class="roman"> and </span><i>last</i> |
| 195 |
are indices of of the first and last characters in the range to |
| 196 |
be deleted. If <i>last</i> isn’t specified it defaults to |
| 197 |
<i>first</i>, i.e. a single character is deleted. This command |
| 198 |
returns an empty string. |
| 199 |
</p></dd> |
| 200 |
<dt><i>pathName </i><b>:get</b></dt> |
| 201 |
<dd><p>Returns the entry’s string. |
| 202 |
</p></dd> |
| 203 |
<dt><i>pathName </i><b>:icursor </b><i>index</i></dt> |
| 204 |
<dd><p>Arrange for the insertion cursor to be displayed just before the character |
| 205 |
given by <i>index</i>. Returns an empty string. |
| 206 |
</p></dd> |
| 207 |
<dt><i>pathName </i><b>:index</b><i> index</i></dt> |
| 208 |
<dd><p>Returns the numerical index corresponding to <i>index</i>. |
| 209 |
</p></dd> |
| 210 |
<dt><i>pathName </i><b>:insert </b><i>index string</i></dt> |
| 211 |
<dd><p>Insert the characters of <i>string</i> just before the character |
| 212 |
indicated by <i>index</i>. Returns an empty string. |
| 213 |
</p></dd> |
| 214 |
<dt><i>pathName </i><b>:scan</b><span class="roman"> </span><i>option args</i></dt> |
| 215 |
<dd><p>This command is used to implement scanning on entries. It has |
| 216 |
two forms, depending on <i>option</i>: |
| 217 |
</p><dl compact="compact"> |
| 218 |
<dt><i>pathName </i><b>:scan :mark </b><i>x</i></dt> |
| 219 |
<dd><p>Records <i>x</i> and the current view in the entry window; used in |
| 220 |
conjunction with later <b>scan dragto</b> commands. Typically this |
| 221 |
command is associated with a mouse button press in the widget. It |
| 222 |
returns an empty string. |
| 223 |
</p></dd> |
| 224 |
<dt><i>pathName </i><b>:scan :dragto </b><i>x</i></dt> |
| 225 |
<dd><p>This command computes the difference between its <i>x</i> argument |
| 226 |
and the <i>x</i><span class="roman"> argument to the last </span><b>scan mark</b> command for |
| 227 |
the widget. It then adjusts the view left or right by 10 times the |
| 228 |
difference in x-coordinates. This command is typically associated |
| 229 |
with mouse motion events in the widget, to produce the effect of |
| 230 |
dragging the entry at high speed through the window. The return |
| 231 |
value is an empty string. |
| 232 |
</p></dd> |
| 233 |
</dl> |
| 234 |
</dd> |
| 235 |
<dt><i>pathName </i><b>:select </b><i>option arg</i></dt> |
| 236 |
<dd><p>This command is used to adjust the selection within an entry. It |
| 237 |
has several forms, depending on <i>option</i>: |
| 238 |
</p><dl compact="compact"> |
| 239 |
<dt><i>pathName </i><b>:select :adjust </b><i>index</i></dt> |
| 240 |
<dd><p>Locate the end of the selection nearest to the character given by |
| 241 |
<i>index</i><span class="roman">, and adjust that end of the selection to be at </span><i>index</i> |
| 242 |
(i.e including but not going beyond <i>index</i>). The other |
| 243 |
end of the selection is made the anchor point for future |
| 244 |
<b>select to</b> commands. If the selection |
| 245 |
isn’t currently in the entry, then a new selection is created to |
| 246 |
include the characters between <i>index</i> and the most recent |
| 247 |
selection anchor point, inclusive. |
| 248 |
Returns an empty string. |
| 249 |
</p></dd> |
| 250 |
<dt><i>pathName </i><b>:select :clear</b></dt> |
| 251 |
<dd><p>Clear the selection if it is currently in this widget. If the |
| 252 |
selection isn’t in this widget then the command has no effect. |
| 253 |
Returns an empty string. |
| 254 |
</p></dd> |
| 255 |
<dt><i>pathName </i><b>:select :from </b><i>index</i></dt> |
| 256 |
<dd><p>Set the selection anchor point to just before the character |
| 257 |
given by <i>index</i>. Doesn’t change the selection. |
| 258 |
Returns an empty string. |
| 259 |
</p></dd> |
| 260 |
<dt><i>pathName </i><b>:select :to </b><i>index</i></dt> |
| 261 |
<dd><p>Set the selection to consist of the elements from the anchor |
| 262 |
point to element <i>index</i>, inclusive. The anchor point is |
| 263 |
determined by the most recent <b>select from</b><span class="roman"> or </span><b>select adjust</b> |
| 264 |
command in this widget. If the selection isn’t in this widget |
| 265 |
then a new selection is created using the most recent anchor point |
| 266 |
specified for the widget. Returns an empty string. |
| 267 |
</p></dd> |
| 268 |
</dl> |
| 269 |
</dd> |
| 270 |
<dt><i>pathName </i><b>:view </b><i>index</i></dt> |
| 271 |
<dd><p>Adjust the view in the entry so that element <i>index</i> is |
| 272 |
at the left edge of the window. Returns an empty string. |
| 273 |
</p> |
| 274 |
</dd> |
| 275 |
</dl> |
| 276 |
<span id="g_t_0022Default-Bindings_0022-3"></span><h4 class="unnumberedsubsec">"Default Bindings"</h4> |
| 277 |
|
| 278 |
<p>Tk automatically creates class bindings for entries that give them |
| 279 |
the following default behavior: |
| 280 |
</p> |
| 281 |
<ul class="no-bullet"> |
| 282 |
<li> [1] |
| 283 |
Clicking mouse button 1 in an entry positions the insertion cursor |
| 284 |
just before the character underneath the mouse cursor and sets the |
| 285 |
input focus to this widget. |
| 286 |
</li><li> [2] |
| 287 |
Dragging with mouse button 1 strokes out a selection between |
| 288 |
the insertion cursor and the character under the mouse. |
| 289 |
</li><li> [3] |
| 290 |
The ends of the selection can be adjusted by dragging with mouse |
| 291 |
button 1 while the shift key is down; this will adjust the end |
| 292 |
of the selection that was nearest to the mouse cursor when button |
| 293 |
1 was pressed. |
| 294 |
</li><li> [4] |
| 295 |
The view in the entry can be adjusted by dragging with mouse button 2. |
| 296 |
</li><li> [5] |
| 297 |
If the input focus is in an entry widget and characters are typed on the |
| 298 |
keyboard, the characters are inserted just before the insertion cursor. |
| 299 |
</li><li> [6] |
| 300 |
Control-h and the Backspace and Delete keys erase the character just |
| 301 |
before the insertion cursor. |
| 302 |
</li><li> [7] |
| 303 |
Control-w erases the word just before the insertion cursor. |
| 304 |
</li><li> [8] |
| 305 |
Control-u clears the entry to an empty string. |
| 306 |
</li><li> [9] |
| 307 |
Control-v inserts the current selection just before the insertion cursor. |
| 308 |
</li><li> [10] |
| 309 |
Control-d deletes the selected characters; an error occurs if the selection |
| 310 |
is not in this widget. |
| 311 |
</li></ul> |
| 312 |
|
| 313 |
<p>If the entry is disabled using the <b>state</b> option, then the entry’s |
| 314 |
view can still be adjusted and text in the entry can still be selected, |
| 315 |
but no insertion cursor will be displayed and no text modifications will |
| 316 |
take place. |
| 317 |
</p> |
| 318 |
<p>The behavior of entries can be changed by defining new bindings for |
| 319 |
individual widgets or by redefining the class bindings. |
| 320 |
</p> |
| 321 |
<span id="Keywords-9"></span><h4 class="unnumberedsubsec">Keywords</h4> |
| 322 |
<p>entry, widget |
| 323 |
</p><hr> |
| 324 |
<div class="header"> |
| 325 |
<p> |
| 326 |
Next: <a href="message.html" accesskey="n" rel="next">message</a>, Previous: <a href="text.html" accesskey="p" rel="prev">text</a>, Up: <a href="Widgets.html" accesskey="u" rel="up">Widgets</a> [<a href="wm.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p> |
| 327 |
</div> |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
</body> |
| 332 |
</html> |