summaryrefslogtreecommitdiffstats
path: root/library/text.tcl
diff options
context:
space:
mode:
authorhobbs <hobbs@noemail.net>2001-12-27 22:26:40 (GMT)
committerhobbs <hobbs@noemail.net>2001-12-27 22:26:40 (GMT)
commit338025721e9c4dbc6dcd5c50e57614e21e22a71b (patch)
treee4b064aac21b465e766a16b4e853df07be7509e2 /library/text.tcl
parentab57530628a3267602ee3c0b0b83e331bd65c593 (diff)
downloadtk-338025721e9c4dbc6dcd5c50e57614e21e22a71b.zip
tk-338025721e9c4dbc6dcd5c50e57614e21e22a71b.tar.gz
tk-338025721e9c4dbc6dcd5c50e57614e21e22a71b.tar.bz2
* library/entry.tcl:
* library/spinbox.tcl: * library/text.tcl: added extra checks against bug #220269 and made spinbox reuse more of the entry procedure code. FossilOrigin-Name: aa3d08e6cc2e73a4a3d1435e884768df97b53a3b
Diffstat (limited to 'library/text.tcl')
-rw-r--r--library/text.tcl55
1 files changed, 43 insertions, 12 deletions
diff --git a/library/text.tcl b/library/text.tcl
index c1a2b54..988466d 100644
--- a/library/text.tcl
+++ b/library/text.tcl
@@ -3,7 +3,7 @@
# This file defines the default bindings for Tk text widgets and provides
# procedures that help in implementing the bindings.
#
-# RCS: @(#) $Id: text.tcl,v 1.18 2001/11/13 00:19:05 hobbs Exp $
+# RCS: @(#) $Id: text.tcl,v 1.19 2001/12/27 22:26:41 hobbs Exp $
#
# Copyright (c) 1992-1994 The Regents of the University of California.
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
@@ -256,7 +256,8 @@ bind Text <<Clear>> {
catch {%W delete sel.first sel.last}
}
bind Text <<PasteSelection>> {
- if {!$tk::Priv(mouseMoved) || $tk_strictMotif} {
+ if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)]
+ || !$tk::Priv(mouseMoved)} {
tk::TextPaste %W %x %y
}
}
@@ -447,20 +448,12 @@ bind Text <Control-h> {
}
bind Text <2> {
if {!$tk_strictMotif} {
- %W scan mark %x %y
- set tk::Priv(x) %x
- set tk::Priv(y) %y
- set tk::Priv(mouseMoved) 0
+ tk::TextScanMark %W %x %y
}
}
bind Text <B2-Motion> {
if {!$tk_strictMotif} {
- if {(%x != $tk::Priv(x)) || (%y != $tk::Priv(y))} {
- set tk::Priv(mouseMoved) 1
- }
- if {$tk::Priv(mouseMoved)} {
- %W scan dragto %x %y
- }
+ tk::TextScanDrag %W %x %y
}
}
set ::tk::Priv(prevPos) {}
@@ -1104,3 +1097,41 @@ proc ::tk::TextPrevPos {w start op} {
}
return 0.0
}
+
+# ::tk::TextScanMark --
+#
+# Marks the start of a possible scan drag operation
+#
+# Arguments:
+# w - The text window from which the text to get
+# x - x location on screen
+# y - y location on screen
+
+proc ::tk::TextScanMark {w x y} {
+ $w scan mark $x $y
+ set ::tk::Priv(x) $x
+ set ::tk::Priv(y) $y
+ set ::tk::Priv(mouseMoved) 0
+}
+
+# ::tk::TextScanDrag --
+#
+# Marks the start of a possible scan drag operation
+#
+# Arguments:
+# w - The text window from which the text to get
+# x - x location on screen
+# y - y location on screen
+
+proc ::tk::TextScanDrag {w x y} {
+ # Make sure these exist, as some weird situations can trigger the
+ # motion binding without the initial press. [Bug #220269]
+ if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x }
+ if {![info exists ::tk::Priv(y)]} { set ::tk::Priv(y) $y }
+ if {($x != $::tk::Priv(x)) || ($y != $::tk::Priv(y))} {
+ set ::tk::Priv(mouseMoved) 1
+ }
+ if {[info exists ::tk::Priv(mouseMoved)] && $::tk::Priv(mouseMoved)} {
+ $w scan dragto $x $y
+ }
+}