spinbox.html

来自「perl教程」· HTML 代码 · 共 1,002 行 · 第 1/3 页

HTML
1,002 行
字号
<dd>
<p>Set the selection anchor point to just before the character
given by <em>index</em>.  Doesn't change the selection.
Returns an empty string.</p>
</dd>
</li>
<dt><strong><a name="item_selectionpresent"><em>$widget</em>-&gt;<strong>selectionPresent</strong>;</a></strong>

<dd>
<p>Returns 1 if there is are characters selected in the Spinbox,
0 if nothing is selected.</p>
</dd>
</li>
<dt><strong><a name="item_selectionrange"><em>$widget</em>-&gt;<strong>selectionRange</strong>(<em>start, </em><em>end</em>);</a></strong>

<dd>
<p>Sets the selection to include the characters starting with
the one indexed by <em>start</em> and ending with the one just
before <em>end</em>.
If <em>end</em> refers to the same character as <em>start</em> or an
earlier one, then the Spinbox's selection is cleared.</p>
</dd>
</li>
<dt><strong><a name="item_selectionto"><em>$widget</em>-&gt;<strong>selectionTo</strong>(<em>index</em>);</a></strong>

<dd>
<p>If <em>index</em> is before the anchor point, set the selection
to the characters from <em>index</em> up to but not including
the anchor point.
If <em>index</em> is the same as the anchor point, do nothing.
If <em>index</em> is after the anchor point, set the selection
to the characters from the anchor point up to but not including
<em>index</em>.
The anchor point is determined by the most recent <strong>select from</strong>
or <strong>select adjust</strong> 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>
</dd>
</li>
</dl>
<dt><strong><a name="item_set"><em>$widget</em>-&gt;<strong>set</strong>(?<em>string</em>?);</a></strong>

<dd>
<p>If <em>string</em> is specified, the Spinbox will try and set it to this
value, otherwise it just returns the Spinbox's string.
If validation is on, it will occur when setting the string.</p>
</dd>
</li>
<dt><strong><a name="item_validate"><em>$widget</em>-&gt;<strong>validate</strong>;</a></strong>

<dd>
<p>This command is used to force an evaluation of the <strong>validateCommand</strong>
independent of the conditions specified by the <strong>validate</strong> option.
This is done by temporarily setting the <strong>validate</strong> option to <strong>all</strong>.
It returns 0 or 1.</p>
</dd>
</li>
<dt><strong><a name="item_xview"><em>$widget</em>-&gt;<strong>xview</strong>(<em>args</em>);</a></strong>

<dd>
<p>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>
</dd>
<dl>
<dt><strong><em>$widget</em>-&gt;<strong>xview</strong>;</strong>

<dd>
<p>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 Spinbox'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 <strong>-xscrollcommand</strong>
option.</p>
</dd>
</li>
<dt><strong><em>$widget</em>-&gt;<strong>xview</strong>(<em>index</em>);</strong>

<dd>
<p>Adjusts the view in the window so that the character given by <em>index</em>
is displayed at the left edge of the window.</p>
</dd>
</li>
<dt><strong><a name="item_xviewmoveto"><em>$widget</em>-&gt;<strong>xviewMoveto</strong>(<em>fraction</em>);</a></strong>

<dd>
<p>Adjusts the view in the window so that the character <em>fraction</em> of the
way through the text appears at the left edge of the window.
<em>Fraction</em> must be a fraction between 0 and 1.</p>
</dd>
</li>
<dt><strong><a name="item_xviewscroll"><em>$widget</em>-&gt;<strong>xviewScroll</strong>(<em>number, what</em>);</a></strong>

<dd>
<p>This command shifts the view in the window left or right according to
<em>number</em> and <em>what</em>.
<em>Number</em> must be an integer.
<em>What</em> must be either <strong>units</strong> or <strong>pages</strong> or an abbreviation
of one of these.
If <em>what</em> is <strong>units</strong>, the view adjusts left or right by
<em>number</em> average-width characters on the display;  if it is
<strong>pages</strong> then the view adjusts by <em>number</em> screenfuls.
If <em>number</em> is negative then characters farther to the left
become visible;  if it is positive then characters farther to the right
become visible.</p>
</dd>
</li>
</dl>
</dl>
<p>
</p>
<hr />
<h1><a name="default_bindings">DEFAULT BINDINGS</a></h1>
<p>Tk automatically creates class bindings for Spinboxes 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>
<dt><strong><a name="item__5b1_5d">[1]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b2_5d">[2]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b3_5d">[3]</a></strong>

<dd>
<p>Triple-clicking with mouse button 1 selects all of the text in the
Spinbox and positions the insertion cursor before the first character.</p>
</dd>
</li>
<dt><strong><a name="item__5b4_5d">[4]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b5_5d">[5]</a></strong>

<dd>
<p>Clicking mouse button 1 with the Control key down will position the
insertion cursor in the Spinbox without affecting the selection.</p>
</dd>
</li>
<dt><strong><a name="item__5b6_5d">[6]</a></strong>

<dd>
<p>If any normal printing characters are typed in a Spinbox, they are
inserted at the point of the insertion cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b7_5d">[7]</a></strong>

<dd>
<p>The view in the Spinbox 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 Spinbox at the position of the mouse cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b8_5d">[8]</a></strong>

<dd>
<p>If the mouse is dragged out of the Spinbox on the left or right sides
while button 1 is pressed, the Spinbox 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>
</dd>
</li>
<dt><strong><a name="item__5b9_5d">[9]</a></strong>

<dd>
<p>The Left and Right keys move the insertion cursor one character to the
left or right;  they also clear any selection in the Spinbox 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>
</dd>
</li>
<dt><strong><a name="item__5b10_5d">[10]</a></strong>

<dd>
<p>The Home key, or Control-a, will move the insertion cursor to the
beginning of the Spinbox and clear any selection in the Spinbox.
Shift-Home moves the insertion cursor to the beginning of the Spinbox
and also extends the selection to that point.</p>
</dd>
</li>
<dt><strong><a name="item__5b11_5d">[11]</a></strong>

<dd>
<p>The End key, or Control-e, will move the insertion cursor to the
end of the Spinbox and clear any selection in the Spinbox.
Shift-End moves the cursor to the end and extends the selection
to that point.</p>
</dd>
</li>
<dt><strong><a name="item__5b12_5d">[12]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b13_5d">[13]</a></strong>

<dd>
<p>Control-/ selects all the text in the Spinbox.</p>
</dd>
</li>
<dt><strong><a name="item__5b14_5d">[14]</a></strong>

<dd>
<p>Control-\ clears any selection in the Spinbox.</p>
</dd>
</li>
<dt><strong><a name="item__5b15_5d">[15]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b16_5d">[16]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b17_5d">[17]</a></strong>

<dd>
<p>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>
</dd>
</li>
<dt><strong><a name="item__5b18_5d">[18]</a></strong>

<dd>
<p>The Delete key deletes the selection, if there is one in the Spinbox.
If there is no selection, it deletes the character to the right of
the insertion cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b19_5d">[19]</a></strong>

<dd>
<p>The BackSpace key and Control-h delete the selection, if there is one
in the Spinbox.
If there is no selection, it deletes the character to the left of
the insertion cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b20_5d">[20]</a></strong>

<dd>
<p>Control-d deletes the character to the right of the insertion cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b21_5d">[21]</a></strong>

<dd>
<p>Meta-d deletes the word to the right of the insertion cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b22_5d">[22]</a></strong>

<dd>
<p>Control-k deletes all the characters to the right of the insertion
cursor.</p>
</dd>
</li>
<dt><strong><a name="item__5b23_5d">[23]</a></strong>

<dd>
<p>Control-t reverses the order of the two characters to the right of
the insertion cursor.</p>
</dd>
<dd>
<p>If the Spinbox is disabled using the <strong>-state</strong> option, then the Spinbox's
view can still be adjusted and text in the Spinbox can still be selected,
but no insertion cursor will be displayed and no text modifications will
take place.</p>
</dd>
<dd>
<p>The behavior of Spinboxes can be changed by defining new bindings for
individual widgets or by redefining the class bindings.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="keywords">KEYWORDS</a></h1>
<p>Spinbox, Entry, widget</p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?