TIP #204: Virtual events for keyboard traversal

From: Joe English (jenglish_at_users.sourceforge.net)
Date: 07/08/04


Date: Thu, 8 Jul 2004 16:35:45 +0000 (UTC)


 TIP #204: VIRTUAL EVENTS FOR KEYBOARD TRAVERSAL
=================================================
 Version: $Revision: 1.1 $
 Author: Joe English <jenglish_at_users.sourceforge.net>
 State: Draft
 Type: Project
 Tcl-Version: 8.5
 Vote: Pending
 Created: Monday, 21 June 2004
 URL: http://purl.org/tcl/tip/204.html
 WebEdit: http://purl.org/tcl/tip/edit/204
 Post-History:

-------------------------------------------------------------------------

 ABSTRACT
==========

 Proposes using two new virtual events, *<<TraverseIn>>* and
 *<<TraverseOut>>*, to notify widgets of keyboard navigation events.

 RATIONALE
===========

 Certain widgets need to perform some action when they receive and/or
 lose keyboard focus because of keyboard traversal. For example, tabbing
 into an Entry or Spinbox widget selects the widget contents.

 This cannot be done with a <FocusIn> binding, since widgets may receive
 <FocusIn> events for reasons other than keyboard traversal.

 Tk currently implements this feature with special-case logic that
 checks the target window's widget class in the /tk::TabToWindow/
 procedure. The drawback to this approach is that it only works for the
 built-in widgets; third party widget sets like
 BWidget[<URL:http://tcllib.sf.net/>],
 IWidgets[<URL:http://sf.net/projects/incrtcl/>], and
 Tile[<URL:http://tktable.sf.net/tile/>] must implement their own
 workarounds.

 PROPOSAL
==========

 Change the standard Tk bindings for <Key-Tab> and <Shift-Key-Tab> to do
 the following:

     * Send a *<<TraverseOut>>* virtual event to the current focus
       window, if any;

     * Set the focus to the new window;

     * Send a *<<TraverseIn>>* virtual event to the new window.

 Additionally, move the current code to handle traversal to Entry and
 Spinbox widgets from /tk::TabToWindow/ to class bindings.

 IMPLEMENTATION
================

 See Tk Patch
 #976928[<URL:http://sourceforge.net/support/tracker.php?aid=976928>].

 The BWidget package has used an identical scheme since version 1.7; see
 Tcllib bug
 #720032[<URL:http://sourceforge.net/support/tracker.php?aid=720032>]
 for details.

 COPYRIGHT
===========

 This document has been placed in the public domain.

-------------------------------------------------------------------------

 TIP AutoGenerator - written by Donal K. Fellows

[[Send Tcl/Tk announcements to tcl-announce@mitchell.org
  Announcements archived at http://groups.yahoo.com/group/tcl_announce/
  Send administrivia to tcl-announce-request@mitchell.org
  Tcl/Tk at http://tcl.tk/ ]]