diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2008-10-17 12:29:25 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2008-10-17 12:29:25 (GMT) |
commit | 729626dc741cec7f605d9982a92dc23bd5a54250 (patch) | |
tree | 86c42b010bed17330aaa230971b7319f92c5aaa2 /library/ttk | |
parent | 61b16774d545ab31705be8fda1520731cb0075f7 (diff) | |
download | tk-729626dc741cec7f605d9982a92dc23bd5a54250.zip tk-729626dc741cec7f605d9982a92dc23bd5a54250.tar.gz tk-729626dc741cec7f605d9982a92dc23bd5a54250.tar.bz2 |
Implemented keyboard bindings for ttk::scale
Diffstat (limited to 'library/ttk')
-rw-r--r-- | library/ttk/scale.tcl | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/library/ttk/scale.tcl b/library/ttk/scale.tcl index 2a5cf2e..19c193f 100644 --- a/library/ttk/scale.tcl +++ b/library/ttk/scale.tcl @@ -2,7 +2,7 @@ # # Bindings for the TScale widget # -# $Id: scale.tcl,v 1.1 2006/10/31 01:42:27 hobbs Exp $ +# $Id: scale.tcl,v 1.2 2008/10/17 12:29:25 patthoyts Exp $ namespace eval ttk::scale { variable State @@ -15,6 +15,25 @@ bind TScale <ButtonPress-1> { ttk::scale::Press %W %x %y } bind TScale <B1-Motion> { ttk::scale::Drag %W %x %y } bind TScale <ButtonRelease-1> { ttk::scale::Release %W %x %y } +bind TScale <ButtonPress-2> { ttk::scale::Jump %W %x %y } +bind TScale <B2-Motion> { ttk::scale::Drag %W %x %y } +bind TScale <ButtonRelease-2> { ttk::scale::Release %W %x %y } + +bind TScale <ButtonPress-3> { ttk::scale::Jump %W %x %y } +bind TScale <B3-Motion> { ttk::scale::Drag %W %x %y } +bind TScale <ButtonRelease-3> { ttk::scale::Release %W %x %y } + +bind TScale <Left> { ttk::scale::Increment %W -1 } +bind TScale <Up> { ttk::scale::Increment %W -1 } +bind TScale <Right> { ttk::scale::Increment %W 1 } +bind TScale <Down> { ttk::scale::Increment %W 1 } +bind TScale <Control-Left> { ttk::scale::Increment %W -10 } +bind TScale <Control-Up> { ttk::scale::Increment %W -10 } +bind TScale <Control-Right> { ttk::scale::Increment %W 10 } +bind TScale <Control-Down> { ttk::scale::Increment %W 10 } +bind TScale <Home> { %W set [%W cget -from] } +bind TScale <End> { %W set [%W cget -to] } + proc ttk::scale::Press {w x y} { variable State set State(dragging) 0 @@ -22,11 +41,8 @@ proc ttk::scale::Press {w x y} { switch -glob -- [$w identify $x $y] { *track - *trough { - if {[$w get $x $y] <= [$w get]} { - ttk::Repeatedly Increment $w -1 - } else { - ttk::Repeatedly Increment $w 1 - } + set inc [expr {([$w get $x $y] <= [$w get]) ? -1 : 1}] + ttk::Repeatedly Increment $w $inc } *slider { set State(dragging) 1 @@ -35,6 +51,26 @@ proc ttk::scale::Press {w x y} { } } +# scale::Jump -- ButtonPress-2/3 binding for scale acts like +# Press except that clicking in the trough jumps to the +# clicked position. +proc ttk::scale::Jump {w x y} { + variable State + set State(dragging) 0 + + switch -glob -- [$w identify $x $y] { + *track - + *trough { + $w set [$w get $x $y] + set State(dragging) 1 + set State(initial) [$w get] + } + *slider { + Press $w $x $y + } + } +} + proc ttk::scale::Drag {w x y} { variable State if {$State(dragging)} { |