beetlebug▾
/

ttk::combobox selection

Gives, sets, or clears the selected text of the field.

PATHNAME selection clear
PATHNAME selection present
PATHNAME selection range START END
PATHNAME selection from INDEX
PATHNAME selection to INDEX
PATHNAME selection adjust INDEX

Description

clear clears the selection. present gives 1 when the field has selected text, else 0. range selects the characters from START up to the character before END.

from sets the anchor of the selection at INDEX. to selects from the anchor to INDEX. adjust moves the end of the selection that is nearer to INDEX to INDEX.

Returns

An empty string, or 1 or 0 for present.

Examples

% ttk::combobox .tcbse
> .tcbse insert 0 hello
> .tcbse selection range 1 3
> list [.tcbse selection present] [.tcbse index sel.first] [.tcbse index sel.last]
1 1 3

% .tcbse selection clear
> .tcbse selection present
0

Errors

% ttk::combobox .tcbse2; .tcbse2 selection range 0
wrong # args: should be ".tcbse2 selection range start end"
-errorcode NONE

% ttk::combobox .tcbse3; .tcbse3 selection bogus
bad selection option "bogus": must be adjust, clear, from, present, range, or to
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also