JDK-4397557 : When a Component does not have focus, key binding for accelerators does not work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.2_08,1.3.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_8
  • CPU: generic,sparc
  • Submitted: 2000-12-13
  • Updated: 2001-06-27
  • Resolved: 2001-06-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Relates :  
Relates :  
Description
This problem entails multiple parts:
*In summary, the accelerators and mnemonics stop working when the mouse pointer
 is on top of a heavyweight component.
*First was filed to java/classes_swing (4395074).  Here is the description:
-----
In a JDialog (or JFrame) with a menubar, mnemonics and accelerators stop 
working when you add a heavyweight component to the content pane.  

I am aware that mixing heavyweight and lightweight components is not 
particularly recommended, but there are situations where this is unavoidable,
such as in our case where we get a Component from JMF.
-----
*This problem was deemed a duplicate of 4344900 and closed as fixed in 1.4.
*Finally, the fix does not quite work and the resulting bug is this one.
 If you use a heavyweight component in a dialog also containing swing component,
 you observe the following behavior:
	If the heavyweight component has focus, the accelerator and mnemonics
	work (in 1.4, using the bug fix for 4344900).
	If a swing component has focus, the accelerator an mnemonics work unless
	the mouse pointer is on top of the heavyweight component.
*Attached is a Test program showing that behavior.

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
24-08-2004

EVALUATION Commit to fix in Merlin. eric.hawkes@eng 2000-12-13 Name: osR10079 Date: 06/19/2001 The cause of this problem is as follows: In this case (when focus on lightweight and mouse pointer on heavyweight button) X creates XEvent which is targeted on heavyweight button. In shouldDispatchToWidget (awt_MToolkit.c) in case of key events we ignore target of XEvent and use result of XmGetFocusWidget() instead. But because in this case focused widget is kind of canvas according to our key events processing strategy we call XtDispatchEvent on our event to use our callback which is registered on our widget of canvas type. But XEvent is targeted on heavyweight button and so XtDispatchEvent() dispatches it on button, but not on frame's canvas as we expect. So, to fix this problem we should, in case of key events, change target of XEvent accordingly with focused widget. ###@###.### 19 Jun 2001 ======================================================================
24-08-2004

WORK AROUND stuart.findlay@ireland 2001-02-09 I have a workaround for this bug which passes the appropriate keyEvent to the parent when needed. See TestFrame_Workaround in the attachments. If any keyEvents are used by the lightweight then obviously these must be attended to before passing.
24-08-2004

SUGGESTED FIX Name: osR10079 Date: 06/19/2001 ###@###.### 19 Jun 2001 ------- awt_MToolkit.c ------- *** /tmp/dwcaydB Fri Jun 15 14:56:47 2001 --- awt_MToolkit.c Fri Jun 15 11:16:59 2001 *************** *** 587,595 **** if (focusWidget == NULL) { if (findWidgetInfo(widget) == NULL) { focusWidget = findTopLevelByShell(widget); - if (focusWidget != NULL) { - win = xev->xkey.window = XtWindow(focusWidget); - } } } --- 587,592 ---- *************** *** 597,602 **** --- 594,600 ---- if ((focusWidget != NULL) && (focusWidget != widget) && (peer = findPeer(&focusWidget)) != NULL) { widget = focusWidget; + win = xev->xkey.window = XtWindow(focusWidget); } } ======================================================================
24-08-2004