beetlebug▾
/

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:

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

See also