From 2e974a2f754624e44ab526d682bd750f440c74d6 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Fri, 17 Oct 2008 12:44:04 +0000 Subject: Backported keyboard bindings for ttk::scale --- ChangeLog | 4 ++++ library/ttk/scale.tcl | 48 ++++++++++++++++++++++++++++++++++++++++++------ 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 + + * library/ttk/scale.tcl: Backported keyboard bindings for ttk::scale + 2008-10-11 Donal K. Fellows *** 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 { ttk::scale::Press %W %x %y } bind TScale { ttk::scale::Drag %W %x %y } bind TScale { ttk::scale::Release %W %x %y } +bind TScale { ttk::scale::Jump %W %x %y } +bind TScale { ttk::scale::Drag %W %x %y } +bind TScale { ttk::scale::Release %W %x %y } + +bind TScale { ttk::scale::Jump %W %x %y } +bind TScale { ttk::scale::Drag %W %x %y } +bind TScale { ttk::scale::Release %W %x %y } + +bind TScale { ttk::scale::Increment %W -1 } +bind TScale { ttk::scale::Increment %W -1 } +bind TScale { ttk::scale::Increment %W 1 } +bind TScale { ttk::scale::Increment %W 1 } +bind TScale { ttk::scale::Increment %W -10 } +bind TScale { ttk::scale::Increment %W -10 } +bind TScale { ttk::scale::Increment %W 10 } +bind TScale { ttk::scale::Increment %W 10 } +bind TScale { %W set [%W cget -from] } +bind TScale { %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)} { -- cgit v0.12