From 46143310c8d375a9451e63ce753d1c654468a98c Mon Sep 17 00:00:00 2001 From: jenglish Date: Tue, 19 Oct 2004 18:56:00 +0000 Subject: TIP #204 "Virtual Events for Keyboard Traversal" (patch #976928) --- ChangeLog | 7 +++++++ library/entry.tcl | 7 ++++++- library/spinbox.tcl | 7 ++++++- library/tk.tcl | 16 +++++++++------- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index cede6f8..549ec20 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-10-19 Joe English + + TIP#204 IMPLEMENTATION + + * library/tk.tcl, library/entry.tcl, library/spinbox.tcl: + TIP #204 "Virtual Events for Keyboard Traversal" (patch #976928) + 2004-10-19 Donal K. Fellows * tests/canvPsImg.tcl, tests/canvPsBmap.tcl: diff --git a/library/entry.tcl b/library/entry.tcl index 2718145..e882972 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -3,7 +3,7 @@ # This file defines the default bindings for Tk entry widgets and provides # procedures that help in implementing those bindings. # -# RCS: @(#) $Id: entry.tcl,v 1.22 2004/03/17 18:15:44 das Exp $ +# RCS: @(#) $Id: entry.tcl,v 1.23 2004/10/19 18:56:01 jenglish Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -69,6 +69,11 @@ bind Entry <> { } } +bind Entry <> { + %W selection range 0 end + %W icursor end +} + # Standard Motif bindings: bind Entry <1> { diff --git a/library/spinbox.tcl b/library/spinbox.tcl index e774e59..d8d2d8a 100644 --- a/library/spinbox.tcl +++ b/library/spinbox.tcl @@ -4,7 +4,7 @@ # procedures that help in implementing those bindings. The spinbox builds # off the entry widget, so it can reuse Entry bindings and procedures. # -# RCS: @(#) $Id: spinbox.tcl,v 1.7 2004/03/17 18:15:45 das Exp $ +# RCS: @(#) $Id: spinbox.tcl,v 1.8 2004/10/19 18:56:01 jenglish Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1997 Sun Microsystems, Inc. @@ -75,6 +75,11 @@ bind Spinbox <> { } } +bind Spinbox <> { + %W selection range 0 end + %W icursor end +} + # Standard Motif bindings: bind Spinbox <1> { diff --git a/library/tk.tcl b/library/tk.tcl index 9daeb69..995083d 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -3,7 +3,7 @@ # Initialization script normally executed in the interpreter for each # Tk-based application. Arranges class bindings for widgets. # -# RCS: @(#) $Id: tk.tcl,v 1.53 2004/03/17 18:15:45 das Exp $ +# RCS: @(#) $Id: tk.tcl,v 1.54 2004/10/19 18:56:01 jenglish Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. @@ -428,19 +428,21 @@ proc ::tk::CancelRepeat {} { } # ::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 <> virtual event to the previous focus window, +# if any, before changing the focus, and a <> 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 <> } focus $w + event generate $w <> } # ::tk::UnderlineAmpersand -- -- cgit v0.12