292 |
manager.processMouseEvent(e); |
manager.processMouseEvent(e); |
293 |
} |
} |
294 |
|
|
295 |
|
private boolean popupVisible() |
296 |
|
{ |
297 |
|
JMenuBar mb = (JMenuBar) ((JMenu)menuItem).getParent(); |
298 |
|
// check if mb.isSelected because if no menus are selected |
299 |
|
// we don't have to look through the list for popup menus |
300 |
|
if (!mb.isSelected()) |
301 |
|
return false; |
302 |
|
for (int i=0;i<mb.getMenuCount();i++) |
303 |
|
if (((JMenu)mb.getComponent(i)).isPopupMenuVisible()) |
304 |
|
return true; |
305 |
|
return false; |
306 |
|
} |
307 |
|
|
308 |
public void mouseEntered(MouseEvent e) |
public void mouseEntered(MouseEvent e) |
309 |
{ |
{ |
310 |
/* When mouse enters menu item, it should be considered selected |
/* When mouse enters menu item, it should be considered selected |
316 |
it will be selected) |
it will be selected) |
317 |
*/ |
*/ |
318 |
JMenu menu = (JMenu) menuItem; |
JMenu menu = (JMenu) menuItem; |
319 |
JMenuBar mb = (JMenuBar) menu.getParent(); |
|
320 |
if (! menu.isTopLevelMenu() |
// NOTE: the following if used to require !menu.isArmed but I could find |
321 |
|| (mb.isSelected() && (((JMenu)(mb.getComponent |
// no reason for this and it was preventing some JDK-compatible behaviour. |
322 |
(mb.getSelectionModel(). |
// Specifically, if a menu is selected but its popup menu not visible, |
323 |
getSelectedIndex()))). |
// and then another menu is selected whose popup menu IS visible, when |
324 |
isPopupMenuVisible()) && ! menu.isArmed())) |
// the mouse is moved over the first menu, its popup menu should become |
325 |
|
// visible. |
326 |
|
|
327 |
|
if (! menu.isTopLevelMenu() || popupVisible()) |
328 |
{ |
{ |
329 |
// set new selection and forward this event to MenuSelectionManager |
// set new selection and forward this event to MenuSelectionManager |
330 |
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); |
MenuSelectionManager manager = MenuSelectionManager.defaultManager(); |