listbox selection
Reads or changes the selected items.
PATHNAME selection anchor INDEX
PATHNAME selection clear FIRST ?LAST?
PATHNAME selection includes INDEX
PATHNAME selection set FIRST ?LAST?
Description
Each form works on the selection of the listbox:
anchor: sets the anchor of the selection to INDEX, for the indexanchor.clear: deselects the items from FIRST to LAST, both included, or the one item at FIRST.includes: gives 1 when the item at INDEX is selected, and 0 when it is not.set: selects the items from FIRST to LAST, both included, or the one item at FIRST. Other selected items stay selected.
These forms send no <<ListboxSelect>> event. A listbox with -state disabled keeps its selection.
Returns
1 or 0 for includes, and an empty string for the other forms.
Examples
% listbox .sl
> .sl insert end a b c d
> .sl selection set 0 2
> .sl selection clear 1
> .sl curselection
0 2
% listbox .sl2
> .sl2 insert end a b
> .sl2 selection set 1
> .sl2 selection includes 1
1
Errors
% listbox .sl3; .sl3 selection bogus 1
bad option "bogus": must be anchor, clear, includes, or set
-errorcode NONE
% listbox .sl4; .sl4 selection set
wrong # args: should be ".sl4 selection option index ?index?"
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1