JDK-6236120 : SwingSet2:Shift-F10 shortcut key is not working to activate popup menu.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: linux_2.6,solaris_9
  • CPU: x86,sparc
  • Submitted: 2005-03-04
  • Updated: 2011-01-19
  • Resolved: 2005-09-07
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.
JDK 6
6 b51Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Bug Info:
=========
Shift-F10 shortcut key is not working to activate popup menu in swingset2 applet application.But the functionality is working fine upto mustang build 23.

JDK Info:
=========
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b25)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b25, mixed mode, sharing)


Sets to Reproduce:
==================
1. Install either jdk1.6.0 b24 or jdk1.6.0 b25

2. Use the following command and launch the application
${JAVA_HOME}/bin/appletviewer ${JAVA_HOME}/demo/jfc/SwingSet2/*.html

3. Press Shift-F10 key

Expected Results:
=================
Popup menu should activate for selecting L&F's.

Actual Results:
===============
Popup menu is not activating.


###@###.### 2005-03-04 10:55:23 GMT

Comments
SUGGESTED FIX Actually putback diffs are here: http://sa.sfbay.sun.com/projects/awt_data/mustang/6236120/
14-11-2005

EVALUATION There is a problem in the Solaris appletviewer - it does not transfer <Shift>-F10 combo to the applet itself. Instead, appletviewer selects its own menu. I'm not sure that this is a bug - it can be documented feature, but there is nothing we can do - we are not even receiving this event. Reassigning to AWT group - supposed that they should deal with the appletviewer problems. ###@###.### 2005-03-04 11:48:32 GMT A regression of 5049146. XWindow.java gets event in handleKeyPress(long ptr) and send it to MenuPeer.handleF10KeyPress(). But method nativeHandleKeyEvent(*) invoke awt_post_java_key_event() in XWindow.c. Should dispatch a java-event before native one. ###@###.### 2005-03-04 13:02:02 GMT Let's consider the behaviour of the frame with menu at the time of the F10 key pressing. On Motif the processing occurs on native level. If we want to consume the F10 event from the user listener, it's failed. But on Windows the event may be consumed. So it would be a good idea to post appropriate Java event (XWindow.c nativeHandleKeyEvent) and at the ending of the processing to invoke the peer method (XMenuBarPeer.handleF10KeyEvent) in order to update MenuBar state. So event may be consumed. Since on Motif the clicking on F10 key cause to generation only the event of the pressing type, so we could sort the invoking of the awt_post_java_key_event. The exception of one is case, if ALT and SHIFT modifiers is on. In this case Motif behaviour is to generate two events: pressing and releasing by the pressing of F10. It's important that if ALT and SHIFT modifiers isn't on, the menu of the frame shouldn't updated. Seems, that it's cause of the disappering of the popup menu in the test case SwingSet2. It would be good idea to postpone fixing of the bug, because nearly the involving code will be changed according to Mustang features (keyboard and menu). it's offered the suggested fix based on out-of-date code. ###@###.### 2005-04-21 11:37:45 GMT
04-03-2005

SUGGESTED FIX ------- XWindow.c ------- *** /tmp/sccs.Im9bll 2005-04-21 14:57:10.902278842 +0400 --- XWindow.c 2005-04-21 14:57:09.290544046 +0400 *************** *** 1199,1205 **** event->type, event->xkey.keycode, event->xkey.state, keysym); DTRACE_PRINTLN1(", AWTkeycode=0x%x", keycode); ! if (post) { awt_post_java_key_event(env, peer, keyEventId, event->xkey.time, --- 1199,1220 ---- event->type, event->xkey.keycode, event->xkey.state, keysym); DTRACE_PRINTLN1(", AWTkeycode=0x%x", keycode); ! Boolean modifiers = False; ! if( (event->xkey.state & ShiftMask) || (event->xkey.state & ControlMask) || (event->xkey.state & AltMask) ) { ! modifiers = True; ! } ! ! // It holds true if we need post java event as a result of F10 action ! Boolean postF10 = False; ! if (keycode != java_awt_event_KeyEvent_VK_F10){ ! postF10 = True; ! } else if(modifiers){ ! postF10 = True; ! } else if(keyEventId == java_awt_event_KeyEvent_KEY_PRESSED){ ! postF10 = True; ! } ! ! if (post && postF10){ awt_post_java_key_event(env, peer, keyEventId, event->xkey.time, ------- XWindow.java ------- *** /tmp/sccs.9E1lT2 2005-04-21 14:58:41.587376627 +0400 --- XWindow.java 2005-04-21 14:58:40.061627036 +0400 *************** *** 833,846 **** return; } final Component currentSource = (Component)getEventSource(); ! if ((nativeHandleKeyEvent(currentSource,KeyEvent.KEY_PRESSED,ev.pData)) == KeyEvent.VK_F10) { ! XToolkit.executeOnEventHandlerThread(currentSource, new Runnable() { ! public void run() { ! handleF10onEDT(currentSource); ! } ! } ! ); ! } } void handleF10onEDT(Component source) { --- 833,839 ---- return; } final Component currentSource = (Component)getEventSource(); ! int keyCode = nativeHandleKeyEvent(currentSource,KeyEvent.KEY_PRESSED,ev.pData); } void handleF10onEDT(Component source) { ------- XFramePeer.java ------- *** /tmp/sccs.wbBR1q 2005-04-21 14:59:19.801903873 +0400 --- XFramePeer.java 2005-04-20 21:32:22.000000000 +0400 *************** *** 623,626 **** --- 623,636 ---- public Rectangle getBoundsPrivate() { return getBounds(); } + + public void handleJavaKeyEvent(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_F10) { + XMenuBarPeer mPeer = getMenubarPeer(); + if (mPeer != null) { + mPeer.handleF10KeyPress(e); + } + } + } + } ------- XMenuBarPeer.java ------- *** /tmp/sccs.GWa1lt 2005-04-21 15:01:02.161377418 +0400 --- XMenuBarPeer.java 2005-04-21 15:01:00.771614943 +0400 *************** *** 449,454 **** --- 449,472 ---- // closeMenuBar(false) and repaint() are called automatically in ungrabInputImpl() } + void handleF10KeyPress(KeyEvent e) { + int keyState = e.getModifiers(); + if (((keyState & InputEvent.ALT_MASK) != 0) || ((keyState & InputEvent.SHIFT_MASK) != 0) || ((keyState & InputEvent.CTRL_MASK) != 0)) + { + return; + } + XMenuPeer l_menu = getMenu(); + if (getMenuSelected() == -1) { + setMenuSelected(0); + grabInput(); + } + else { + ungrabInput(); + // closeMenuBar(false) is called automatically in ungrabInputImpl() + } + repaint(); + } + void handleF10KeyPress() { XMenuPeer l_menu = getMenu(); if (getMenuSelected() == -1) { ###@###.### 2005-04-21 11:37:45 GMT
04-03-2005

WORK AROUND It's possible to select L&F using MenuBar. ###@###.### 2005-04-14 14:54:16 GMT
04-03-2005