Attachment "tk-traversal-events.patch" to
ticket [976928ff]
added by
jenglish
2004-09-21 01:32:49.
Date: Sat Sep 18 15:26:44 PDT 2004
Files: library/tk.tcl library/entry.tcl library/spinbox.tcl
Tip: 204
Bugid: #976928
--- library/tk.tcl.traversal-events.old 2004-07-09 17:35:59.000000000 -0700
+++ library/tk.tcl 2004-09-18 15:20:17.000000000 -0700
@@ -428,19 +428,21 @@
}
# ::tk::TabToWindow --
-# This procedure moves the focus to the given widget. If the widget
-# is an entry or a spinbox, it selects the entire contents of the widget.
+# This procedure moves the focus to the given widget.
+# It sends a <<TraverseOut>> virtual event to the previous focus window,
+# if any, before changing the focus, and a <<TraverseIn>> event
+# to the new focus window afterwards.
#
# Arguments:
# w - Window to which focus should be set.
proc ::tk::TabToWindow {w} {
- if {[string equal [winfo class $w] Entry] \
- || [string equal [winfo class $w] Spinbox]} {
- $w selection range 0 end
- $w icursor end
+ set focus [focus]
+ if {$focus ne ""} {
+ event generate $focus <<TraverseOut>>
}
focus $w
+ event generate $w <<TraverseIn>>
}
# ::tk::UnderlineAmpersand --
--- library/entry.tcl.traversal-events.old 2004-03-24 12:16:46.000000000 -0800
+++ library/entry.tcl 2004-09-18 15:26:21.000000000 -0700
@@ -69,6 +69,11 @@
}
}
+bind Entry <<TraverseIn>> {
+ %W selection range 0 end
+ %W icursor end
+}
+
# Standard Motif bindings:
bind Entry <1> {
--- library/spinbox.tcl.traversal-events.old 2004-03-24 12:16:46.000000000 -0800
+++ library/spinbox.tcl 2004-09-18 15:26:38.000000000 -0700
@@ -75,6 +75,11 @@
}
}
+bind Spinbox <<TraverseIn>> {
+ %W selection range 0 end
+ %W icursor end
+}
+
# Standard Motif bindings:
bind Spinbox <1> {