diff options
Diffstat (limited to 'library/spinbox.tcl')
-rw-r--r-- | library/spinbox.tcl | 116 |
1 files changed, 62 insertions, 54 deletions
diff --git a/library/spinbox.tcl b/library/spinbox.tcl index cb501ee..1965ed8 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -52,7 +52,6 @@ bind Spinbox <<Copy>> { } } bind Spinbox <<Paste>> { - global tcl_platform catch { if {[tk windowingsystem] ne "x11"} { catch { @@ -74,8 +73,8 @@ bind Spinbox <<PasteSelection>> { } bind Spinbox <<TraverseIn>> { - %W selection range 0 end - %W icursor end + %W selection range 0 end + %W icursor end } # Standard Motif bindings: @@ -87,10 +86,12 @@ bind Spinbox <B1-Motion> { ::tk::spinbox::Motion %W %x %y } bind Spinbox <Double-1> { + ::tk::spinbox::ArrowPress %W %x %y set tk::Priv(selectMode) word ::tk::spinbox::MouseSelect %W %x sel.first } bind Spinbox <Triple-1> { + ::tk::spinbox::ArrowPress %W %x %y set tk::Priv(selectMode) line ::tk::spinbox::MouseSelect %W %x 0 } @@ -120,52 +121,52 @@ bind Spinbox <Control-1> { %W icursor @%x } -bind Spinbox <Up> { +bind Spinbox <<PrevLine>> { %W invoke buttonup } -bind Spinbox <Down> { +bind Spinbox <<NextLine>> { %W invoke buttondown } -bind Spinbox <Left> { +bind Spinbox <<PrevChar>> { ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] } -bind Spinbox <Right> { +bind Spinbox <<NextChar>> { ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] } -bind Spinbox <Shift-Left> { +bind Spinbox <<SelectPrevChar>> { ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}] ::tk::EntrySeeInsert %W } -bind Spinbox <Shift-Right> { +bind Spinbox <<SelectNextChar>> { ::tk::EntryKeySelect %W [expr {[%W index insert] + 1}] ::tk::EntrySeeInsert %W } -bind Spinbox <Control-Left> { +bind Spinbox <<PrevWord>> { ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] } -bind Spinbox <Control-Right> { +bind Spinbox <<NextWord>> { ::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert] } -bind Spinbox <Shift-Control-Left> { +bind Spinbox <<SelectPrevWord>> { ::tk::EntryKeySelect %W [::tk::EntryPreviousWord %W insert] ::tk::EntrySeeInsert %W } -bind Spinbox <Shift-Control-Right> { +bind Spinbox <<SelectNextWord>> { ::tk::EntryKeySelect %W [::tk::EntryNextWord %W insert] ::tk::EntrySeeInsert %W } -bind Spinbox <Home> { +bind Spinbox <<LineStart>> { ::tk::EntrySetCursor %W 0 } -bind Spinbox <Shift-Home> { +bind Spinbox <<SelectLineStart>> { ::tk::EntryKeySelect %W 0 ::tk::EntrySeeInsert %W } -bind Spinbox <End> { +bind Spinbox <<LineEnd>> { ::tk::EntrySetCursor %W end } -bind Spinbox <Shift-End> { +bind Spinbox <<SelectLineEnd>> { ::tk::EntryKeySelect %W end ::tk::EntrySeeInsert %W } @@ -193,10 +194,10 @@ bind Spinbox <Control-Shift-space> { bind Spinbox <Shift-Select> { %W selection adjust insert } -bind Spinbox <Control-slash> { +bind Spinbox <<SelectAll>> { %W selection range 0 end } -bind Spinbox <Control-backslash> { +bind Spinbox <<SelectNone>> { %W selection clear } bind Spinbox <KeyPress> { @@ -215,6 +216,8 @@ bind Spinbox <Escape> {# nothing} bind Spinbox <Return> {# nothing} bind Spinbox <KP_Enter> {# nothing} bind Spinbox <Tab> {# nothing} +bind Spinbox <Prior> {# nothing} +bind Spinbox <Next> {# nothing} if {[tk windowingsystem] eq "aqua"} { bind Spinbox <Command-KeyPress> {# nothing} } @@ -229,31 +232,11 @@ if {[tk windowingsystem] ne "win32"} { # Additional emacs-like bindings: -bind Spinbox <Control-a> { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W 0 - } -} -bind Spinbox <Control-b> { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}] - } -} bind Spinbox <Control-d> { if {!$tk_strictMotif} { %W delete insert } } -bind Spinbox <Control-e> { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W end - } -} -bind Spinbox <Control-f> { - if {!$tk_strictMotif} { - ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}] - } -} bind Spinbox <Control-h> { if {!$tk_strictMotif} { ::tk::EntryBackspace %W @@ -318,6 +301,10 @@ bind Spinbox <B2-Motion> { proc ::tk::spinbox::Invoke {w elem} { variable ::tk::Priv + if {![winfo exists $w]} { + return + } + if {![info exists Priv(outsideElement)]} { $w invoke $elem incr Priv(repeated) @@ -347,6 +334,35 @@ proc ::tk::spinbox::ClosestGap {w x} { incr pos } +# ::tk::spinbox::ArrowPress -- +# This procedure is invoked to handle button-1 presses in buttonup +# or buttondown elements of spinbox widgets. +# +# Arguments: +# w - The spinbox window in which the button was pressed. +# x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. + +proc ::tk::spinbox::ArrowPress {w x y} { + variable ::tk::Priv + + if {[$w cget -state] ne "disabled" && \ + [string match "button*" $Priv(element)]} { + $w selection element $Priv(element) + set Priv(repeated) 0 + set Priv(relief) [$w cget -$Priv(element)relief] + catch {after cancel $Priv(afterId)} + set delay [$w cget -repeatdelay] + if {$delay > 0} { + set Priv(afterId) [after $delay \ + [list ::tk::spinbox::Invoke $w $Priv(element)]] + } + if {[info exists Priv(outsideElement)]} { + unset Priv(outsideElement) + } + } +} + # ::tk::spinbox::ButtonDown -- # This procedure is invoked to handle button-1 presses in spinbox # widgets. It moves the insertion cursor, sets the selection anchor, @@ -355,6 +371,7 @@ proc ::tk::spinbox::ClosestGap {w x} { # Arguments: # w - The spinbox window in which the button was pressed. # x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. proc ::tk::spinbox::ButtonDown {w x y} { variable ::tk::Priv @@ -369,20 +386,7 @@ proc ::tk::spinbox::ButtonDown {w x y} { switch -exact $Priv(element) { "buttonup" - "buttondown" { - if {"disabled" ne [$w cget -state]} { - $w selection element $Priv(element) - set Priv(repeated) 0 - set Priv(relief) [$w cget -$Priv(element)relief] - catch {after cancel $Priv(afterId)} - set delay [$w cget -repeatdelay] - if {$delay > 0} { - set Priv(afterId) [after $delay \ - [list ::tk::spinbox::Invoke $w $Priv(element)]] - } - if {[info exists Priv(outsideElement)]} { - unset Priv(outsideElement) - } - } + ::tk::spinbox::ArrowPress $w $x $y } "entry" { set Priv(selectMode) char @@ -394,7 +398,8 @@ proc ::tk::spinbox::ButtonDown {w x y} { $w selection clear } default { - return -code error "unknown spinbox element \"$Priv(element)\"" + return -code error -errorcode {TK SPINBOX UNKNOWN_ELEMENT} \ + "unknown spinbox element \"$Priv(element)\"" } } } @@ -406,6 +411,7 @@ proc ::tk::spinbox::ButtonDown {w x y} { # Arguments: # w - The spinbox window in which the button was pressed. # x - The x-coordinate of the button press. +# y - The y-coordinate of the button press. proc ::tk::spinbox::ButtonUp {w x y} { variable ::tk::Priv @@ -509,6 +515,8 @@ proc ::tk::spinbox::Paste {w x} { # # Arguments: # w - The spinbox window. +# x - The x-coordinate of the mouse. +# y - The y-coordinate of the mouse. proc ::tk::spinbox::Motion {w x y} { variable ::tk::Priv |