diff options
author | patthoyts <patthoyts@users.sourceforge.net> | 2008-10-17 12:44:04 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@users.sourceforge.net> | 2008-10-17 12:44:04 (GMT) |
commit | 16dd69b94a648274c5b855d9ad24b24f0c0ef919 (patch) | |
tree | e6451660cd6ea27315fb1cd8952475223e187c24 /library/ttk | |
parent | 3186295ce79b4515254bc719abb2e0e2f1fc8758 (diff) | |
download | tk-16dd69b94a648274c5b855d9ad24b24f0c0ef919.zip tk-16dd69b94a648274c5b855d9ad24b24f0c0ef919.tar.gz tk-16dd69b94a648274c5b855d9ad24b24f0c0ef919.tar.bz2 |
Backported 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..b660809 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.1.4.1 2008/10/17 12:44:04 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)} { |