536 lines
24 KiB
HTML
536 lines
24 KiB
HTML
<HTML><HEAD><TITLE>Tk Built-In Commands - listbox manual page</TITLE></HEAD>
|
|
<BR>
|
|
<BODY bgcolor = #c3c3ff>
|
|
<H2><IMG ALIGN=BOTTOM SRC="./Img/ManPageBlue.gif"> listbox</H2>
|
|
<I>Create and manipulate listbox widgets</I><P><IMG ALIGN=TOP SRC="./Img/line-red.gif">
|
|
<H3><A NAME="M2">SYNOPSIS</A></H3>
|
|
(<B>listbox</B><I> widget-name </I>?<I>options</I>?)<BR>
|
|
<H3><A NAME="M3">STANDARD OPTIONS</A></H3>
|
|
<PRE>
|
|
<B><A HREF="options.n.html#M:background">:background</A></B> <B><A HREF="options.n.html#M:borderwidth">:borderwidth</A></B>
|
|
<B><A HREF="options.n.html#M:cursor">:cursor</A></B> <B><A HREF="options.n.html#M:exportselection">:exportselection</A></B>
|
|
<B><A HREF="options.n.html#M:font">:font</A></B> <B><A HREF="options.n.html#M:foreground">:foreground</A></B>
|
|
<B><A HREF="options.n.html#M:height">:height</A></B> <B><A HREF="options.n.html#M:highlightbackground">:highlightbackground</A></B>
|
|
<B><A HREF="options.n.html#M:highlightcolor">:highlightcolor</A></B> <B><A HREF="options.n.html#M:highlightthickness">:highlightthickness</A></B>
|
|
<B><A HREF="options.n.html#M:relief">:relief</A></B> <B><A HREF="options.n.html#M:selectbackground">:selectbackground</A></B>
|
|
<B><A HREF="options.n.html#M:selectborderwidth">:selectborderwidth</A></B> <B><A HREF="options.n.html#M:selectforeground">:selectforeground</A></B>
|
|
<B><A HREF="options.n.html#M:setgrid">:setgrid</A></B> <B><A HREF="options.n.html#M:takefocus">:takefocus</A></B>
|
|
<B><A HREF="options.n.html#M:width">:width</A></B> <B><A HREF="options.n.html#M:xscrollcommand">:xscrollcommand</A></B>
|
|
<B><A HREF="options.n.html#M:yscrollcommand">:yscrollcommand</A></B>
|
|
</PRE>
|
|
<H3><A NAME="M23">WIDGET-SPECIFIC OPTIONS</A></H3>
|
|
<DL>
|
|
<P>
|
|
<DT><I>Name</I>: <B>height</B>
|
|
<DT><I>Class</I>: <B>Height</B>
|
|
<DT><I>Option keyword</I>: <B><A NAME="M24">:height</A></B>
|
|
<DT><I>STklos slot name</I>: <B>height</B>
|
|
<DD>Specifies the desired height for the window, in lines.
|
|
If zero or less, then the desired height for the window is made just
|
|
large enough to hold all the elements in the listbox.
|
|
<P>
|
|
<P>
|
|
<DT><I>Name</I>: <B>selectMode</B>
|
|
<DT><I>Class</I>: <B>SelectMode</B>
|
|
<DT><I>Option keyword</I>: <B><A NAME="M25">:selectmode</A></B>
|
|
<DT><I>STklos slot name</I>: <B>select-mode</B>
|
|
<DD>Speifies one of several styles for manipulating the selection.
|
|
The value of the option may be arbitrary, but the default bindings
|
|
expect it to be either <B>single</B>, <B>browse</B>, <B>multiple</B>,
|
|
or <B>extended</B>; the default value is <B>browse</B>.
|
|
<P>
|
|
<P>
|
|
<DT><I>Name</I>: <B>width</B>
|
|
<DT><I>Class</I>: <B>Width</B>
|
|
<DT><I>Option keyword</I>: <B><A NAME="M26">:width</A></B>
|
|
<DT><I>STklos slot name</I>: <B>width</B>
|
|
<DD>Specifies the desired width for the window in characters.
|
|
If the font doesn't have a uniform width then the width of the
|
|
character ``0'' is used in translating from character units to
|
|
screen units.
|
|
If zero or less, then the desired width for the window is made just
|
|
large enough to hold all the elements in the listbox.
|
|
<P>
|
|
</DL>
|
|
<H3><A NAME="M27">DESCRIPTION</A></H3>
|
|
The <B>listbox</B> procedure creates a new window (given by the
|
|
<I>widget-name</I> argument) and makes it into a listbox widget.
|
|
Additional
|
|
options, described above, may be specified on the procedure line
|
|
or in the option database
|
|
to configure aspects of the listbox such as its colors, font,
|
|
text, and relief. The <B>listbox</B> procedure returns its
|
|
<I>widget-name</I> argument. At the time this procedure is invoked,
|
|
there must not exist a window named <I>widget-name</I>, but
|
|
<I>widget-name</I>'s parent must exist.
|
|
<P>
|
|
A listbox is a widget that displays a list of strings, one per line.
|
|
When first created, a new listbox has no elements.
|
|
Elements may be added or deleted using widget procedures described
|
|
below. In addition, one or more elements may be selected as described
|
|
below.
|
|
If a listbox is exporting its selection (see <B>exportSelection</B>
|
|
option), then it will observe the standard X11 protocols
|
|
for handling the selection.
|
|
Listbox selections are available as type <B>STRING</B>;
|
|
the value of the selection will be the text of the selected elements, with
|
|
newlines separating the elements.
|
|
<P>
|
|
It is not necessary for all the elements to be
|
|
displayed in the listbox window at once; procedures described below
|
|
may be used to change the view in the window. Listboxes allow
|
|
scrolling in both directions using the standard <B>xScrollProcedure</B>
|
|
and <B>yScrollProcedure</B> options.
|
|
They also support scanning, as described below.
|
|
|
|
<H3><A NAME="M28">INDICES</A></H3>
|
|
Many of the widget procedures for listboxes take one or more indices
|
|
as arguments.
|
|
An index specifies a particular element of the listbox, in any of
|
|
the following ways:
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M29"><I>number</I></A><DD>
|
|
Specifies the element as a numerical index, where 0 corresponds
|
|
to the first element in the listbox.
|
|
<P>
|
|
<DT><A NAME="M30"><B>active</B></A><DD>
|
|
Indicates the element that has the location cursor. This element
|
|
will be displayed with an underline when the listbox has the
|
|
keyboard focus, and it is specified with the <B>activate</B>
|
|
widget procedure.
|
|
<P>
|
|
<DT><A NAME="M31"><B>anchor</B></A><DD>
|
|
Indicates the anchor point for the selection, which is set with the
|
|
``<I>selection anchor</I>'' widget procedure.
|
|
<P>
|
|
<DT><A NAME="M32"><B>end</B></A><DD>
|
|
Indicates the end of the listbox.
|
|
For most procedure this refers to the last element in the listbox,
|
|
but for a few procedure such as <B>index</B> and <B>insert</B>
|
|
it refers to the element just after the last one.
|
|
<P>
|
|
<DT><A NAME="M33"><B>@</B><I>x</I><B>,</B><I>y</I></A><DD>
|
|
Indicates the element that covers the point in the listbox window
|
|
specified by <I>x</I> and <I>y</I> (in pixel coordinates). If no
|
|
element covers that point, then the closest element to that
|
|
point is used.
|
|
<P>
|
|
</DL>
|
|
<P>
|
|
In the widget procedure descriptions below, arguments named <I>index</I>,
|
|
<I>first</I>, and <I>last</I> always contain text indices in one of
|
|
the above forms.
|
|
|
|
<H3><A NAME="M34">WIDGET PROCEDURE</A></H3>
|
|
The <B>listbox</B> procedure creates a new STk procedure whose
|
|
name is <I>widget-name</I>. This
|
|
procedure may be used to invoke various
|
|
operations on the widget. It has the following general form:
|
|
<PRE>(<I>widget-name option </I>?<I>arg arg ...</I>?)</PRE>
|
|
<I>Option</I> and the <I>arg</I>s
|
|
determine the exact behavior of the procedure. The following
|
|
procedures are possible for listbox widgets:
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M35">(<I>widget-name '</I><B>activate</B> <I>index</I>)</A><DD>
|
|
Sets the active element to the one indicated by <I>index</I>.
|
|
If <I>index</I> is outside the range of elements in the listbox
|
|
then the closest element is activated.
|
|
The active element is drawn with an underline when the widget
|
|
has the input focus, and its index may be retrieved with the
|
|
index <B>active</B>.
|
|
<P>
|
|
<DT><A NAME="M36">(<I>widget-name '</I><B>bbox</B> <I>index</I>)</A><DD>
|
|
Returns a list of four numbers describing the bounding box of
|
|
the text in the element 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 text
|
|
(specified in pixels relative to the widget) and the last two
|
|
elements give the width and height of the area, in pixels.
|
|
If no part of the element given by <I>index</I> is visible on the
|
|
screen,
|
|
or if <I>index</I> refers to a non-existent element,
|
|
then the result is an empty list; if the element is
|
|
partially visible, the result gives the full area of the element,
|
|
including any parts that are not visible.
|
|
<P>
|
|
<DT><A NAME="M37">(<I>widget-name '</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>listbox</B>
|
|
procedure.
|
|
<P>
|
|
<DT><A NAME="M38">(<I>widget-name '</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>widget-name</I> (see <B>Tk_ConfigureInfo</B> for
|
|
information on the format of this list). If <I>option</I> is specified
|
|
with no <I>value</I>, then the procedure 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 procedure
|
|
modifies the given widget option(s) to have the given value(s); in
|
|
this case the procedure returns an empty list.
|
|
<I>Option</I> may have any of the values accepted by the <B>listbox</B>
|
|
procedure.
|
|
<P>
|
|
<DT><A NAME="M39">(<I>widget-name '</I><B>curselection</B>)</A><DD>
|
|
Returns a list containing the numerical indices of
|
|
all of the elements in the listbox that are currently selected.
|
|
If there are no elements selected in the listbox then <B>#f</B>
|
|
is returned.
|
|
<P>
|
|
<DT><A NAME="M40">(<I>widget-name '</I><B>delete </B><I>first</I>)</A><DD>
|
|
<DT><A NAME="M41">(<I>widget-name '</I><B>delete </B><I>first </I><I>last</I>)</A><DD>
|
|
Deletes one or more elements of the listbox. <I>First</I> and <I>last</I>
|
|
are indices specifying the first and last elements in the range
|
|
to delete. If <I>last</I> isn't specified it defaults to
|
|
<I>first</I>, i.e. a single element is deleted.
|
|
<P>
|
|
<DT><A NAME="M42">(<I>widget-name '</I><B>get </B><I>first</I>)</A><DD>
|
|
<DT><A NAME="M43">(<I>widget-name '</I><B>get </B><I>first</I> <I>last</I>)</A><DD>
|
|
If <I>last</I> is omitted, returns the contents of the listbox
|
|
element indicated by <I>first</I>,
|
|
or an empty list if <I>first</I> refers to a non-existent element.
|
|
If <I>last</I> is specified, the procedure returns a list whose elements
|
|
are all of the listbox elements between <I>first</I> and <I>last</I>,
|
|
inclusive.
|
|
Both <I>first</I> and <I>last</I> may have any of the standard
|
|
forms for indices.
|
|
<P>
|
|
<DT><A NAME="M44">(<I>widget-name '</I><B>index </B><I>index</I>)</A><DD>
|
|
Returns the integer index value that corresponds to <I>index</I>.
|
|
If <I>index</I> is <B>end</B> the return value is a count of the number
|
|
of elements in the listbox (not the index of the last element).
|
|
<P>
|
|
<DT><A NAME="M45">(<I>widget-name '</I><B>insert </B><I>index </I>?<I>element element ...</I>?)</A><DD>
|
|
Inserts zero or more new elements in the list just before the
|
|
element given by <I>index</I>. If <I>index</I> is specified as
|
|
<B>end</B> then the new elements are added to the end of the
|
|
list. Returns an empty list.
|
|
<P>
|
|
<DT><A NAME="M46">(<I>widget-name '</I><B>nearest </B><I>y</I>)</A><DD>
|
|
Given a y-coordinate within the listbox window, this procedure returns
|
|
the index of the (visible) listbox element nearest to that y-coordinate.
|
|
<P>
|
|
<DT><A NAME="M47">(<I>widget-name '</I><B>scan</B> <I>option args</I>)</A><DD>
|
|
This procedure is used to implement scanning on listboxes. It has
|
|
two forms, depending on <I>option</I>:
|
|
<P>
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M48">(<I>widget-name '</I><B>scan 'mark </B><I>x y</I>)</A><DD>
|
|
Records <I>x</I> and <I>y</I> and the current view in the listbox
|
|
window; used in conjunction with later <B>scan dragto</B> procedures.
|
|
Typically this procedure is associated with a mouse button press in
|
|
the widget. It returns an empty list.
|
|
<P>
|
|
<DT><A NAME="M49">(<I>widget-name '</I><B>scan 'dragto </B><I>x y</I>)</A><DD>
|
|
This procedure computes the difference between its <I>x</I> and <I>y</I>
|
|
arguments and the <I>x</I> and <I>y</I> arguments to the last
|
|
<B>scan mark</B> procedure for the widget.
|
|
It then adjusts the view by 10 times the
|
|
difference in coordinates. This procedure is typically associated
|
|
with mouse motion events in the widget, to produce the effect of
|
|
dragging the list at high speed through the window. The return
|
|
value is an empty list.
|
|
<P>
|
|
</DL>
|
|
<DT><A NAME="M50">(<I>widget-name '</I><B>see </B><I>index</I>)</A><DD>
|
|
Adjust the view in the listbox so that the element given by <I>index</I>
|
|
is visible.
|
|
If the element is already visible then the procedure has no effect;
|
|
if the element is near one edge of the window then the listbox
|
|
scrolls to bring the element into view at the edge; otherwise
|
|
the listbox scrolls to center the element.
|
|
<P>
|
|
<DT><A NAME="M51">(<I>widget-name '</I><B>selection </B><I>option arg</I>)</A><DD>
|
|
This procedure is used to adjust the selection within a listbox. It
|
|
has several forms, depending on <I>option</I>:
|
|
<P>
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M52">(<I>widget-name </I><B>'selection 'anchor </B><I>index</I>)</A><DD>
|
|
Sets the selection anchor to the element given by <I>index</I>.
|
|
If <I>index</I> refers to a non-existent element, then the closest
|
|
element is used.
|
|
The selection anchor is the end of the selection that is fixed
|
|
while dragging out a selection with the mouse.
|
|
The index <B>anchor</B> may be used to refer to the anchor
|
|
element.
|
|
<P>
|
|
<DT><A NAME="M53">(<I>widget-name </I><B>'selection 'clear </B><I>first</I>)</A><DD>
|
|
<DT><A NAME="M54">(<I>widget-name </I><B>'selection 'clear </B><I>first </I><I>last</I>)</A><DD>
|
|
If any of the elements between <I>first</I> and <I>last</I>
|
|
(inclusive) are selected, they are deselected.
|
|
The selection state is not changed for elements outside
|
|
this range.
|
|
<P>
|
|
<DT><A NAME="M55">(<I>widget-name </I><B>'selection 'includes </B><I>index</I>)</A><DD>
|
|
Returns #t if the element indicated by <I>index</I> is currently
|
|
selected, #f if it isn't.
|
|
<P>
|
|
<DT><A NAME="M56">(<I>widget-name </I><B>'selection 'set </B><I>first</I>)</A><DD>
|
|
<DT><A NAME="M57">(<I>widget-name </I><B>'selection 'set </B><I>first </I><I>last</I>)</A><DD>
|
|
Selects all of the elements in the range between
|
|
<I>first</I> and <I>last</I>, inclusive, without affecting
|
|
the selection state of elements outside that range.
|
|
<P>
|
|
</DL>
|
|
<DT><A NAME="M58">(<I>widget-name '</I><B>size</B>)</A><DD>
|
|
Returns a decimal string indicating the total number of elements
|
|
in the listbox.
|
|
<P>
|
|
<DT><A NAME="M59">(<I>widget-name '</I><B>xview </B><I>args</I>)</A><DD>
|
|
This procedure is used to query and change the horizontal position of the
|
|
information in the widget's window. It can take any of the following
|
|
forms:
|
|
<P>
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M60">(<I>widget-name '</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 listbox'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>:xscrollprocedure</B>
|
|
option.
|
|
<P>
|
|
<DT><A NAME="M61">(<I>widget-name '</I><B>xview</B> <I>index</I>)</A><DD>
|
|
Adjusts the view in the window so that the character position given by
|
|
<I>index</I> is displayed at the left edge of the window.
|
|
Character positions are defined by the width of the character <B>0</B>.
|
|
<P>
|
|
<DT><A NAME="M62">(<I>widget-name </I><B>'xview 'moveto</B><I> fraction</I>)</A><DD>
|
|
Adjusts the view in the window so that <I>fraction</I> of the
|
|
total width of the listbox text is off-screen to the left.
|
|
<I>fraction</I> must be a fraction between 0 and 1.
|
|
<P>
|
|
<DT><A NAME="M63">(<I>widget-name </I><B>'xview 'scroll </B><I>number what</I>)</A><DD>
|
|
This procedure 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> character units (the width of the <B>0</B> character)
|
|
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>
|
|
<DT><A NAME="M64">(<I>widget-name '</I><B>yview </B><I>?args</I>?)</A><DD>
|
|
This procedure is used to query and change the vertical position of the
|
|
text in the widget's window.
|
|
It can take any of the following forms:
|
|
<P>
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M65">(<I>widget-name '</I><B>yview</B>)</A><DD>
|
|
Returns a list containing two elements, both of which are real fractions
|
|
between 0 and 1.
|
|
The first element gives the position of the listbox element at the
|
|
top of the window, relative to the listbox as a whole (0.5 means
|
|
it is halfway through the listbox, for example).
|
|
The second element gives the position of the listbox element just after
|
|
the last one in the window, relative to the listbox as a whole.
|
|
These are the same values passed to scrollbars via the <B>:yscrollprocedure</B>
|
|
option.
|
|
<P>
|
|
<DT><A NAME="M66">(<I>widget-name '</I><B>yview</B> <I>index</I>)</A><DD>
|
|
Adjusts the view in the window so that the element given by
|
|
<I>index</I> is displayed at the top of the window.
|
|
<P>
|
|
<DT><A NAME="M67">(<I>widget-name </I><B>'yview 'moveto</B><I> fraction</I>)</A><DD>
|
|
Adjusts the view in the window so that the element given by <I>fraction</I>
|
|
appears at the top of the window.
|
|
<I>Fraction</I> is a fraction between 0 and 1; 0 indicates the first
|
|
element in the listbox, 0.33 indicates the element one-third the
|
|
way through the listbox, and so on.
|
|
<P>
|
|
<DT><A NAME="M68">(<I>widget-name </I><B>'yview 'scroll </B><I>number what</I>)</A><DD>
|
|
This procedure adjusts the view in the window up or down 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>.
|
|
If <I>what</I> is <B>units</B>, the view adjusts up or down by
|
|
<I>number</I> lines; if it is <B>pages</B> then
|
|
the view adjusts by <I>number</I> screenfuls.
|
|
If <I>number</I> is negative then earlier elements
|
|
become visible; if it is positive then later elements
|
|
become visible.
|
|
<P>
|
|
</DL>
|
|
</DL>
|
|
<H3><A NAME="M69">DEFAULT BINDINGS</A></H3>
|
|
Tk automatically creates class bindings for listboxes that give them
|
|
Motif-like behavior. Much of the behavior of a listbox is determined
|
|
by its <B>selectMode</B> option, which selects one of four ways
|
|
of dealing with the selection.
|
|
<P>
|
|
If the selection mode is <B>single</B> or <B>browse</B>, at most one
|
|
element can be selected in the listbox at once.
|
|
In both modes, clicking button 1 on an element selects
|
|
it and deselects any other selected item.
|
|
In <B>browse</B> mode it is also possible to drag the selection
|
|
with button 1.
|
|
<P>
|
|
If the selection mode is <B>multiple</B> or <B>extended</B>,
|
|
any number of elements may be selected at once, including discontiguous
|
|
ranges. In <B>multiple</B> mode, clicking button 1 on an element
|
|
toggles its selection state without affecting any other elements.
|
|
In <B>extended</B> mode, pressing button 1 on an element selects
|
|
it, deselects everything else, and sets the anchor to the element
|
|
under the mouse; dragging the mouse with button 1
|
|
down extends the selection to include all the elements between
|
|
the anchor and the element under the mouse, inclusive.
|
|
<P>
|
|
Most people will probably want to use <B>browse</B> mode for
|
|
single selections and <B>extended</B> mode for multiple selections;
|
|
the other modes appear to be useful only in special situations.
|
|
<P>
|
|
In addition to the above behavior, the following additional behavior
|
|
is defined by the default bindings:
|
|
<P>
|
|
<DL>
|
|
<DT><A NAME="M70">{[1]}</A><DD>
|
|
In <B>extended</B> mode, the selected range can be adjusted by pressing
|
|
button 1 with the Shift key down: this modifies the selection to
|
|
consist of the elements between the anchor and the element under
|
|
the mouse, inclusive.
|
|
The un-anchored end of this new selection can also be dragged with
|
|
the button down.
|
|
<P>
|
|
<DT><A NAME="M71">{[2]}</A><DD>
|
|
In <B>extended</B> mode, pressing button 1 with the Control key down
|
|
starts a toggle operation: the anchor is set to the element under
|
|
the mouse, and its selection state is reversed. The selection state
|
|
of other elements isn't changed.
|
|
If the mouse is dragged with button 1 down, then the selection state
|
|
of all elements between the anchor and the element under the mouse
|
|
is set to match that of the anchor element; the selection state of
|
|
all other elements remains what it was before the toggle operation
|
|
began.
|
|
<P>
|
|
<DT><A NAME="M72">{[3]}</A><DD>
|
|
If the mouse leaves the listbox window with button 1 down, the window
|
|
scrolls away from the mouse, making information visible that used
|
|
to be off-screen on the side of the mouse.
|
|
The scrolling continues until the mouse re-enters the window, the
|
|
button is released, or the end of the listbox is reached.
|
|
<P>
|
|
<DT><A NAME="M73">{[4]}</A><DD>
|
|
Mouse button 2 may be used for scanning.
|
|
If it is pressed and dragged over the listbox, the contents of
|
|
the listbox drag at high speed in the direction the mouse moves.
|
|
<P>
|
|
<DT><A NAME="M74">{[5]}</A><DD>
|
|
If the Up or Down key is pressed, the location cursor (active
|
|
element) moves up or down one element.
|
|
If the selection mode is <B>browse</B> or <B>extended</B> then the
|
|
new active element is also selected and all other elements are
|
|
deselected.
|
|
In <B>extended</B> mode the new active element becomes the
|
|
selection anchor.
|
|
<P>
|
|
<DT><A NAME="M75">{[6]}</A><DD>
|
|
In <B>extended</B> mode, Shift-Up and Shift-Down move the location
|
|
cursor (active element) up or down one element and also extend
|
|
the selection to that element in a fashion similar to dragging
|
|
with mouse button 1.
|
|
<P>
|
|
<DT><A NAME="M76">{[7]}</A><DD>
|
|
The Left and Right keys scroll the listbox view left and right
|
|
by the width of the character <B>0</B>.
|
|
Control-Left and Control-Right scroll the listbox view left and
|
|
right by the width of the window.
|
|
Control-Prior and Control-Next also scroll left and right by
|
|
the width of the window.
|
|
<P>
|
|
<DT><A NAME="M77">{[8]}</A><DD>
|
|
The Prior and Next keys scroll the listbox view up and down
|
|
by one page (the height of the window).
|
|
<P>
|
|
<DT><A NAME="M78">{[9]}</A><DD>
|
|
The Home and End keys scroll the listbox horizontally to
|
|
the left and right edges, respectively.
|
|
<P>
|
|
<DT><A NAME="M79">{[10]}</A><DD>
|
|
Control-Home sets the location cursor to the the first element in
|
|
the listbox, selects that element, and deselects everything else
|
|
in the listbox.
|
|
<P>
|
|
<DT><A NAME="M80">{[11]}</A><DD>
|
|
Control-End sets the location cursor to the the last element in
|
|
the listbox, selects that element, and deselects everything else
|
|
in the listbox.
|
|
<P>
|
|
<DT><A NAME="M81">{[12]}</A><DD>
|
|
In <B>extended</B> mode, Control-Shift-Home extends the selection
|
|
to the first element in the listbox and Control-Shift-End extends
|
|
the selection to the last element.
|
|
<P>
|
|
<DT><A NAME="M82">{[13]}</A><DD>
|
|
In <B>multiple</B> mode, Control-Shift-Home moves the location cursor
|
|
to the first element in the listbox and Control-Shift-End moves
|
|
the location cursor to the last element.
|
|
<P>
|
|
<DT><A NAME="M83">{[14]}</A><DD>
|
|
The space and Select keys make a selection at the location cursor
|
|
(active element) just as if mouse button 1 had been pressed over
|
|
this element.
|
|
<P>
|
|
<DT><A NAME="M84">{[15]}</A><DD>
|
|
In <B>extended</B> mode, Control-Shift-space and Shift-Select
|
|
extend the selection to the active element just as if button 1
|
|
had been pressed with the Shift key down.
|
|
<P>
|
|
<DT><A NAME="M85">{[16]}</A><DD>
|
|
In <B>extended</B> mode, the Escape key cancels the most recent
|
|
selection and restores all the elements in the selected range
|
|
to their previous selection state.
|
|
<P>
|
|
<DT><A NAME="M86">{[17]}</A><DD>
|
|
Control-slash selects everything in the widget, except in
|
|
<B>single</B> and <B>browse</B> modes, in which case it selects
|
|
the active element and deselects everything else.
|
|
<P>
|
|
<DT><A NAME="M87">{[18]}</A><DD>
|
|
Control-backslash deselects everything in the widget, except in
|
|
<B>browse</B> mode where it has no effect.
|
|
<P>
|
|
<DT><A NAME="M88">{[19]}</A><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>
|
|
</DL>
|
|
<P>
|
|
The behavior of listboxes can be changed by defining new bindings for
|
|
individual widgets or by redefining the class bindings.
|
|
|
|
<H3><A NAME="M89">EXAMPLE</A></H3>
|
|
Herafter is an example of a listbox connected to a scrollbar
|
|
<PRE>;; Create list box and scrollbar
|
|
(listbox '.l :height 5
|
|
:yscroll (lambda l (apply .s 'set l)))
|
|
(scrollbar '.s :command (lambda l (apply .l 'yview l)))
|
|
|
|
;; Set some elements in the listbox
|
|
(.l 'insert 0 'one 'two 'three 'four 'five 'six 'seven 'eight)
|
|
|
|
;; Pack elements
|
|
(pack .l :side "left" :expand #t :fill "both")
|
|
(pack .s :side "right" :expand #f :fill "y")</PRE>
|
|
<H3><A NAME="M90">SEE ALSO</A></H3>
|
|
<B><A HREF="./scrollbar.n.html">scrollbar</A></B>
|
|
<P><IMG ALIGN=TOP SRC="./Img/line-red.gif"><P>
|
|
<A HREF=./STk-hlp.html><IMG ALIGN=BOTTOM SRC="./Img/RefBookBlue.gif"> Back to the <B>STk</B> main page</A>
|
|
</BODY></HTML>
|