ttk::combobox current
Gives the index of the text in -values, or sets the text to a value of the list.
PATHNAME current ?INDEX?
Description
With no INDEX, gives the index in -values of the text of the field, or -1 when the text is not in the list. With INDEX, sets the text to that value of the list. INDEX is a number from 0 or end.
Returns
An index, or an empty string.
Examples
% ttk::combobox .tcbcu -values {red green blue}
> list [.tcbcu current] [.tcbcu current 2] [.tcbcu get] [.tcbcu current]
-1 {} blue 2
% ttk::combobox .tcbcu2 -values {red green}
> .tcbcu2 set purple
> .tcbcu2 current
-1
Errors
% ttk::combobox .tcbcu3 -values {a b}; .tcbcu3 current 5
Index 5 out of range
-errorcode NONE
% ttk::combobox .tcbcu4 -values {a b}; .tcbcu4 current x
Incorrect index x
-errorcode NONE
% ttk::combobox .tcbcu5; .tcbcu5 current 1 2
wrong # args: should be ".tcbcu5 current ?newIndex?"
-errorcode NONE
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1