summaryrefslogtreecommitdiffstats
path: root/library/spinbox.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/spinbox.tcl')
-rw-r--r--library/spinbox.tcl80
1 files changed, 33 insertions, 47 deletions
diff --git a/library/spinbox.tcl b/library/spinbox.tcl
index 0e26644..4303141 100644
--- a/library/spinbox.tcl
+++ b/library/spinbox.tcl
@@ -4,10 +4,10 @@
# procedures that help in implementing those bindings. The spinbox builds
# off the entry widget, so it can reuse Entry bindings and procedures.
#
-# Copyright (c) 1992-1994 The Regents of the University of California.
-# Copyright (c) 1994-1997 Sun Microsystems, Inc.
-# Copyright (c) 1999-2000 Jeffrey Hobbs
-# Copyright (c) 2000 Ajuba Solutions
+# Copyright © 1992-1994 The Regents of the University of California.
+# Copyright © 1994-1997 Sun Microsystems, Inc.
+# Copyright © 1999-2000 Jeffrey Hobbs
+# Copyright © 2000 Ajuba Solutions
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -79,31 +79,31 @@ bind Spinbox <<TraverseIn>> {
# Standard Motif bindings:
-bind Spinbox <1> {
+bind Spinbox <Button-1> {
::tk::spinbox::ButtonDown %W %x %y
}
bind Spinbox <B1-Motion> {
::tk::spinbox::Motion %W %x %y
}
-bind Spinbox <Double-1> {
+bind Spinbox <Double-Button-1> {
::tk::spinbox::ArrowPress %W %x %y
set tk::Priv(selectMode) word
::tk::spinbox::MouseSelect %W %x sel.first
}
-bind Spinbox <Triple-1> {
+bind Spinbox <Triple-Button-1> {
::tk::spinbox::ArrowPress %W %x %y
set tk::Priv(selectMode) line
::tk::spinbox::MouseSelect %W %x 0
}
-bind Spinbox <Shift-1> {
+bind Spinbox <Shift-Button-1> {
set tk::Priv(selectMode) char
%W selection adjust @%x
}
-bind Spinbox <Double-Shift-1> {
+bind Spinbox <Double-Shift-Button-1> {
set tk::Priv(selectMode) word
::tk::spinbox::MouseSelect %W %x
}
-bind Spinbox <Triple-Shift-1> {
+bind Spinbox <Triple-Shift-Button-1> {
set tk::Priv(selectMode) line
::tk::spinbox::MouseSelect %W %x
}
@@ -117,7 +117,7 @@ bind Spinbox <B1-Enter> {
bind Spinbox <ButtonRelease-1> {
::tk::spinbox::ButtonUp %W %x %y
}
-bind Spinbox <Control-1> {
+bind Spinbox <Control-Button-1> {
%W icursor @%x
}
@@ -129,17 +129,17 @@ bind Spinbox <<NextLine>> {
}
bind Spinbox <<PrevChar>> {
- ::tk::EntrySetCursor %W [expr {[%W index insert] - 1}]
+ ::tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert]
}
bind Spinbox <<NextChar>> {
- ::tk::EntrySetCursor %W [expr {[%W index insert] + 1}]
+ ::tk::EntrySetCursor %W [tk::EntryNextChar %W insert]
}
bind Spinbox <<SelectPrevChar>> {
- ::tk::EntryKeySelect %W [expr {[%W index insert] - 1}]
+ ::tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert]
::tk::EntrySeeInsert %W
}
bind Spinbox <<SelectNextChar>> {
- ::tk::EntryKeySelect %W [expr {[%W index insert] + 1}]
+ ::tk::EntryKeySelect %W [tk::EntryNextChar %W insert]
::tk::EntrySeeInsert %W
}
bind Spinbox <<PrevWord>> {
@@ -153,7 +153,7 @@ bind Spinbox <<SelectPrevWord>> {
::tk::EntrySeeInsert %W
}
bind Spinbox <<SelectNextWord>> {
- ::tk::EntryKeySelect %W [::tk::EntryNextWord %W insert]
+ ::tk::EntryKeySelect %W [::tk::EntrySelectNextWord %W insert]
::tk::EntrySeeInsert %W
}
bind Spinbox <<LineStart>> {
@@ -175,7 +175,8 @@ bind Spinbox <Delete> {
if {[%W selection present]} {
%W delete sel.first sel.last
} else {
- %W delete insert
+ %W delete [tk::startOfCluster [%W get] [%W index insert]] \
+ [tk::endOfCluster [%W get] [%W index insert]]
}
}
bind Spinbox <BackSpace> {
@@ -204,7 +205,7 @@ bind Spinbox <Key> {
::tk::EntryInsert %W %A
}
-# Ignore all Alt, Meta, Control, and Mod4 keypresses unless explicitly bound.
+# Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound.
# Otherwise, if a widget binding for one of these is defined, the
# <Key> class binding will also fire and insert the character,
# which is wrong. Ditto for Escape, Return, and Tab.
@@ -218,10 +219,8 @@ 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-Key> {# nothing}
- bind Spinbox <Mod4-Key> {# nothing}
-}
+bind Spinbox <Command-Key> {# nothing}
+bind Spinbox <Fn-Key> {# nothing}
# On Windows, paste is done using Shift-Insert. Shift-Insert already
# generates the <<Paste>> event, so we don't need to do anything here.
@@ -281,27 +280,14 @@ bind Spinbox <Meta-Delete> {
# A few additional bindings of my own.
-if {[tk windowingsystem] ne "aqua"} {
- bind Spinbox <2> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanMark %W %x
- }
- }
- bind Spinbox <B2-Motion> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanDrag %W %x
- }
- }
-} else {
- bind Spinbox <3> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanMark %W %x
- }
+bind Spinbox <Button-2> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanMark %W %x
}
- bind Spinbox <B3-Motion> {
- if {!$tk_strictMotif} {
- ::tk::EntryScanDrag %W %x
- }
+}
+bind Spinbox <B2-Motion> {
+ if {!$tk_strictMotif} {
+ ::tk::EntryScanDrag %W %x
}
}
@@ -483,11 +469,11 @@ proc ::tk::spinbox::MouseSelect {w x {cursor {}}} {
}
word {
if {$cur < [$w index anchor]} {
- set before [tcl_wordBreakBefore [$w get] $cur]
- set after [tcl_wordBreakAfter [$w get] $anchor-1]
+ set before [tk::wordBreakBefore [$w get] $cur]
+ set after [tk::wordBreakAfter [$w get] $anchor-1]
} else {
- set before [tcl_wordBreakBefore [$w get] $anchor]
- set after [tcl_wordBreakAfter [$w get] $cur-1]
+ set before [tk::wordBreakBefore [$w get] $anchor]
+ set after [tk::wordBreakAfter [$w get] $cur-1]
}
if {$before < 0} {
set before 0
@@ -590,5 +576,5 @@ proc ::tk::spinbox::AutoScan {w} {
proc ::tk::spinbox::GetSelection {w} {
return [string range [$w get] [$w index sel.first] \
- [expr {[$w index sel.last] - 1}]]
+ [$w index sel.last]-1]
}