From 729626dc741cec7f605d9982a92dc23bd5a54250 Mon Sep 17 00:00:00 2001 From: patthoyts Date: Fri, 17 Oct 2008 12:29:25 +0000 Subject: Implemented 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 d02bf55..922ef39 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-10-17 Pat Thoyts + + * library/ttk/scale.tcl: Implemented keyboard bindings for ttk::scale + 2008-10-15 Jan Nijtmans * generic/tkInt.h: Add "const" to many internal 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 { 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