1 # scale.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
3 # Bindings for the TScale widget
5 namespace eval ttk
::scale {
12 bind TScale
<ButtonPress-1
> { ttk
::scale::Press %W
%x
%y
}
13 bind TScale
<B1-Motion
> { ttk
::scale::Drag %W
%x
%y
}
14 bind TScale
<ButtonRelease-1
> { ttk
::scale::Release %W
%x
%y
}
16 bind TScale
<ButtonPress-2
> { ttk
::scale::Jump %W
%x
%y
}
17 bind TScale
<B2-Motion
> { ttk
::scale::Drag %W
%x
%y
}
18 bind TScale
<ButtonRelease-2
> { ttk
::scale::Release %W
%x
%y
}
20 bind TScale
<ButtonPress-3
> { ttk
::scale::Jump %W
%x
%y
}
21 bind TScale
<B3-Motion
> { ttk
::scale::Drag %W
%x
%y
}
22 bind TScale
<ButtonRelease-3
> { ttk
::scale::Release %W
%x
%y
}
24 bind TScale
<Left
> { ttk
::scale::Increment %W
-1 }
25 bind TScale
<Up
> { ttk
::scale::Increment %W
-1 }
26 bind TScale
<Right
> { ttk
::scale::Increment %W
1 }
27 bind TScale
<Down
> { ttk
::scale::Increment %W
1 }
28 bind TScale
<Control-Left
> { ttk
::scale::Increment %W
-10 }
29 bind TScale
<Control-Up
> { ttk
::scale::Increment %W
-10 }
30 bind TScale
<Control-Right
> { ttk
::scale::Increment %W
10 }
31 bind TScale
<Control-Down
> { ttk
::scale::Increment %W
10 }
32 bind TScale
<Home
> { %W
set [%W cget
-from] }
33 bind TScale
<End
> { %W
set [%W cget
-to] }
35 proc ttk
::scale::Press {w x y
} {
39 switch -glob -- [$w identify
$x $y] {
42 set inc
[expr {([$w get
$x $y] <= [$w get
]) ?
-1 : 1}]
43 ttk
::Repeatedly Increment
$w $inc
47 set State
(initial
) [$w get
]
52 # scale::Jump -- ButtonPress-2/3 binding for scale acts like
53 # Press except that clicking in the trough jumps to the
55 proc ttk
::scale::Jump {w x y
} {
59 switch -glob -- [$w identify
$x $y] {
64 set State
(initial
) [$w get
]
72 proc ttk
::scale::Drag {w x y
} {
74 if {$State(dragging
)} {
79 proc ttk
::scale::Release {w x y
} {
85 proc ttk
::scale::Increment {w delta
} {
86 if {![winfo exists
$w]} return
87 $w set [expr {[$w get
] + $delta}]