JDK-4056074 : no way to grab a key and tie it to a specific event w/ the new event model
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.1.1,1.1.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_95
  • CPU: x86,sparc
  • Submitted: 1997-06-02
  • Updated: 2004-03-04
  • Resolved: 2004-03-04
Related Reports
Duplicate :  
Duplicate :  
Description
<linda.schneider@eng 6/2/97>

There doesnt seem to "grab" a key event and always have a function
be called (e.g. like a menushort cut w/o a menu associated w. a frame)

e.g. we need to be able to hit the F1 key over any dialog or window and
have the help panel come up (since we are not using a menubar ...we cant
use a menu shortcut)

(in the old event model, you just had each window respond to the F1 which
was propogated up from where it was selected)

The only way to do this with the current event model is to set up a 
key listener on every component as it is created .... a bit wasteful
since the key events are already being passed up for menushortcuts 
and tab events.

Since the old event API's are going away at somepoint ... it would
be nice to have a way to do this in the jdk

Comments
EVALUATION We could consider this for Tiger. eric.hawkes@eng 2000-03-01 Name: osR10079 Date: 03/02/2004 In fact we already have API to get all key events (even two :) These are KeyEventDispatchers and KeyEventPostProcessors (see FocusSpec and KeyboardFocusManager for details). They were introduced in 1.4. So, I'd suggest to close this RFE as implemented. ###@###.### Mar 3, 2004 ====================================================================== Name: osR10079 Date: 03/03/2004 Required functionality was by implementation for 4290675 (Focus Management Enhancements) ###@###.### Mar 4, 2004 ======================================================================
24-08-2004

SUGGESTED FIX <linda.schneider@eng 6/2/97> add a list of key events w/ associated listeners to Frame maybe with an interface like: public void addGrabKey(KeyCode key, KeyListener listen); public void removeGrabKey(KeyCode key); public void removeGrabKey(KeyListener listener); handle processing the events in Frame:preProcessKeyEvent e.g. void preProcessKeyEvent(KeyEvent e) { if (menuBar != null && menuBar.handleShortcut(e)) { e.consume(); return; } if (handleKeyGrab(e)) { // handle key grab should check if one/more listeners // have requested a grab on the key and if so, call // the listeners w/ the event e.consume(); return; } super.preProcessKeyEvent(e); }
24-08-2004