1 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 # TODO: reassess signals(valid) when the contents changes (set method, typing, etc)
6 inherit tlc::Mywidget tlc::Baselog tlc::Signalsource tlc::Handlers
14 variable initialvalue ""
16 method state {args} {return [$w.c state {*}$args]}
17 method instate {args} {return [$w.c instate {*}$args]}
18 method get {} {return [$w.c get]}
19 method set {} {return [$w.c set]}
20 method current {args} {return [$w.c current {*}$args]}
24 method newselection {}
29 configbody tlc::Combobox::initialvalue { #<<<
30 $w.c set $initialvalue
34 configbody tlc::Combobox::state { #<<<
36 if {"disabled" in $state} {
37 lappend states "disabled"
39 lappend states "!disabled"
46 configbody tlc::Combobox::readonly { #<<<
47 if {"readonly" in $state} {
48 lappend states "readonly"
50 lappend states "!readonly"
56 body tlc::Combobox::constructor {args} { #<<<
57 tlc::Signal #auto signals(valid) -name "$w valid"
59 itk_component add combobox {
62 keep -values -exportselection -justify -height -postcommand
63 keep -textvariable -width
65 itk_initialize {*}$args
67 pack $w.c -fill both -expand true
69 $signals(valid) set_state [expr {[$w.c current] != -1}]
71 bind $w.c <<ComboboxSelected>> [code $this newselection]
75 body tlc::Combobox::destructor {} { #<<<
79 body tlc::Combobox::newselection {} { #<<<
80 $signals(valid) set_state [expr {[$w.c current] != -1}]
81 invoke_handlers onselect [$w.c get]