Posted to tcl by Emiliano at Wed Aug 15 16:59:46 GMT 2007view raw
- proc ttk::text {wname args} {
- namespace eval text {}
- set tname $wname.txt
- entry $wname -state disabled
- #bindtags $wname [list $wname [winfo toplevel $wname] all]
- eval ::text $tname $args
- $tname configure -borderwidth 0 -highlightthickness 0
- pack $tname -padx 2 -pady 2 -expand 1 -fill both
- uplevel #0 [list rename $wname ::ttk::text::$wname]
- uplevel #0 [list interp alias {} $wname {} $tname]
- bind $tname <FocusIn> [list ::ttk::text::$wname state focus]
- bind $tname <FocusOut> [list ::ttk::text::$wname state !focus]
- bind $tname <Destroy> [list destroy $wname]
- return $wname
- }
- pack [ttk::text .t -bg white -width 40 -height 15 ] -padx 10 -pady 10
- pack [ttk::button .b -text "Hello"] -pady {0 10}
Comments
Posted by Emiliano at Wed Aug 15 23:07:31 GMT 2007 [text] [code]
Problem solved. Final code is: proc ttk::text {wname args} { namespace eval text {} set tname $wname.txt entry $wname -state disabled -takefocus 0 bindtags $wname None_at_all eval ::text $tname $args $tname configure -borderwidth 0 -highlightthickness 0 bind $tname <Shift-Key-ISO_Left_Tab> [format {tk::TabToWindow [tk_focusPrev %s];break} $wname] pack $tname -padx 2 -pady 2 -expand 1 -fill both uplevel #0 [list rename $wname ::ttk::text::$wname] uplevel #0 [list interp alias {} $wname {} $tname] bind $tname <FocusIn> [list ::ttk::text::$wname state focus] bind $tname <FocusOut> [list ::ttk::text::$wname state !focus] bind $tname <Destroy> [list destroy $wname] bind None_at_all <FocusIn> {tk::TabToWindow [tk_focusNext %W]} return $wname } pack [ttk::text .t -bg white -width 40 -height 15 ] -padx 10 -pady 10 pack [ttk::button .b -text "Hello"] -pady {0 10} ttk::setTheme clam Now the keyboard traversal works right for the cases of tk_focusNext and tk_focusPrev