summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--library/ttk/scale.tcl48
2 files changed, 46 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index e166976..4760f95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-17 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * library/ttk/scale.tcl: Backported keyboard bindings for ttk::scale
+
2008-10-11 Donal K. Fellows <donal.k.fellows@man.ac.uk>
*** 8.5.5 TAGGED FOR RELEASE ***
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)} {