Posted to tcl by jeremy_c at Sat Jan 30 19:54:55 GMT 2010view raw
- # Focus Race... Drop down a combo box and watch
- # your CPU and Memory fly sky high!
- #
- # In my app, the focus race was not so obvious as the <FocusIn> type calls were in
- # different snit::widgets and made sense when a widget stood alone, but when they
- # started adding up and then the parent having a <FocusIn> as well, things went
- # crazy.! Select an item from one of the drop downs, that causes everything to loose focus
- # and the drop down list window gets focus. As soon as that widget gives focus back
- # to the parent, be ready to hit the kill process button!
- package require Tk
- ttk::frame .f1
- ttk::combobox .f1.c1 -values {A B C}
- pack .f1.c1
- bind .f1 <FocusIn> { focus -force .f1.c1 }
- ttk::frame .f2
- ttk::combobox .f2.c2 -values {D E F}
- pack .f2.c2
- bind .f2 <FocusIn> { focus -force .f2.c2 }
- pack .f1 .f2
- bind . <FocusIn> { focus -force .f1 }