JDK-6544309 : PIT:Unable to select the item's in 'input method selection' popupmenu by using keyboard.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u2
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2007-04-10
  • Updated: 2011-03-07
  • Resolved: 2011-03-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 JDK 7
6u4Fixed 7 b15Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
BugInfo:
========
Unable to select the items in 'input method selection' popup menu by using keyboard.I can able select the items only through mouse.Even Esc key is also not working for dispose the popupmenu.

Focus is not gaining to popup menu from parent when it shows on parent so that unable to select the items through keyboard.
By default popup menu is not gaining the focus till click on popup menu item.Once focus gains then we can able to select the items by keyboard.

6492266 is a partial fix.The fix is not working for above mentioned scenarios.

JDK Info:
=========
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b01)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode)

Steps to Reproduce:
====================
1. Copy CodePointIM.jar file from jfc demo into '${JAVA_HOME}/jre/lib/ext' folder.
2. Run a swing webstart application that have a text field, e.g., Bugster.
3. Place the focus on text field.
4. Show the 'input method selection' popup menu.Click on the system icon on the top-left corner of the frame and then select "Select Input Method" menu item.
5. Popup menu is actually displayed.
6. Select the menu items through keyboard.

Expected Behavior:
=================
Should select the popup menu items using arrows keys.

Actual Behavior:
=================
Unable to select the items using arrow keys.Only user can able to select through mouse.
I found a couple of new problems with the 'Select InnputMethod' menu: 
   1. A menu item cannot be selected with keyboard even if you can go through menu items with arrow keys. I.e. SPACE or ENTER don't make an action.
   2. If mouse cursor is above the menu and then it is moved outside the menu, the menu loses the focus and cannot be handled with keyboard.

Comments
EVALUATION As I found, the main cause of the bug is described here 4212563. Then several fixes were made, but it did not remove all the problems. The fix for this bug should solve them.
21-06-2007

SUGGESTED FIX webrev: http://javaweb.sfbay/jcg/7/swing/6544309/ mail-archive: http://sa.sfbay.sun.com/mail-archive/6544309 The fix for 6492266 turned out not so good. Some annoying problems weren't eliminated. The problem was in the fact, that the IM menu is handled by different EDT than it's parent. The fix made the menu always heavyweight. I invited a new simple approach. All the problems will be solved if the menu and it's parent will be handled with the same EDT. I wrote a code, which finds EDT of the menu parent and uses it to show the menu. Also I found and fixed a related problem, which consists in IM menu inaccessibility for keyboard input just after menu appearance. The cause is in BasicPopupMenuUI.MenuKeyboardHelper.stateChanged() method. The method is responsible also for finding of a popup menu invoker and for assigning an input map to it. Now if the invoker is JDialog, the input map isn't assigned. A couple of lines of code fixed the problem. Finally, I had to cut off a part of the test case for 6492266 because, in fact, I partially rolled back the fix for 6492266.
14-06-2007

WORK AROUND Use mouse to select items from the Input Method Selection popup menu.
14-06-2007

EVALUATION It's not a regression. 'Select Input Method' menu behaves in the same wrong way even in 1.5 (I tested 1.5.0_08). The fix for 6492266 removes a regression from 6280964, but not fixes this problem. In fact, the problem appeared when menu keyboard handling had been moved to menu parent's root pane. As I found if the parent is a JDialog, a child popup menu cannot be handled with keyboard at all.
26-04-2007

EVALUATION --------- The problem of 'Select Input Method' menu inaccessibility for keyboard input just after it's appearance: The cause is in BasicPopupMenuUI.MenuKeyboardHelper.stateChanged() method. The method is responsible also for finding of a popup menu invoker and for assigning an input map to it. Now if the invoker is JDialog, the input map isn't assigned. Look at the code: Component c = popup.getInvoker(); if(c instanceof JFrame) { invoker = ((JFrame)c).getRootPane(); } else if(c instanceof JApplet) { invoker = ((JApplet)c).getRootPane(); } else { while (!(c instanceof JComponent)) { if (c == null) { return; } c = c.getParent(); } invoker = (JComponent)c; } An addition of the following two lines almost solves the problem: } else if(c instanceof JDialog) { invoker = ((JDialog)c).getRootPane(); Also we should ensure that keyboard events are serviced by proper EDT (see the explanation of second problem's cause below). It can be achieved by requesting focus for the popup menu window. --------- The problem consisting in an impossibility to close 'Select Input Method' menu clicking by mouse outside the menu: As I supposed, the problem has the same nature as 6492266. The menu and the parent dialog window are serviced by different EDTs. When user clicks somewhere inside the dialog, BasicPopupMenuUI.cancelPopupMenu() is called to close all opened popups. However the method closes only popups, which are serviced by current EDT. So the menu, belonging to the other EDT, remains opened. I don't have an idea how to fix the problem in the general way, but for 'Select Input Method' menu it can be almost fixed with a menu's FocusListener. When the focus is gone, menu should be closed.
20-04-2007

EVALUATION Really there is the problem with 'input method selection' menu. It doesn't get the focus when it appears. All keyboard input is received by the parent window. However, you can make keyboard working in the menu. For this purpose you should place mouse cursor above the menu and keyboard will start work. Most likely the problem with focus is not connected with 6492266, because the menu doesn't get focus even in 1.5. There is one more problem: if you click somewhere in parent window while the menu is shown, the menu won't be closed, although it should. I almost sure that the second problem is a regression of 6280964 when mouse grabber and keyboard helper became sored in application context.
19-04-2007