JDK-8090449 : Mac: SQE needs API to determine current menu state on Mac
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: fx2.1
  • Priority: P2
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2011-12-22
  • Updated: 2018-09-05
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
tbdUnresolved
Related Reports
Blocks :  
Description
It should be possible to find current menu state from java code. The way it is done for Swing, JMenuBar and JMenuItem and JMenu components, although invisible, reflect selected/expanded properties which are actually set in Mac OS X native menu. It does not matter whether this would be done the same way in FX or somehow differently as long as a test code is able to determine menu/submenu selection. 

This is required for automation of single app menu bar testing. Rest could be done similar to how it is done in Jemmy v2 for Swing. 
Comments
The link provided in the previous comment does not work. Could you please specify some more details on the needed API? Currently glass Menu on the Mac supports an EventHandler which reports about MenuOpened and MenuClosed event. Would adding a callback for an event when native Menu highlights an item be sufficient for your needs?
26-04-2013

https://java.net/projects/jemmy/sources/jemmy2/content/trunk/Jemmy2/src/org/netbeans/jemmy/drivers/menus/AppleMenuDriver.java?rev=105
26-04-2013

Rising to critical as this is a blocker for test automation of Mac menu testing
23-04-2013

Not part of the FX 8 PRD, consider for future release
23-04-2013

I have investigated getting the highlight state of a menu item and the following seem to work for menu items that are not in the menu bar: NSMenu.highlightedItem() NSMenuItem.isHighlighted() I don't see any other API that can be used. I will check with Apple and confirm.
12-01-2012

I was asked to investigate getting the bounds of a menu item in Cocoa. I believe this to be impossible and remember going back and forth with Apple on this (ask Scott). I would love to be proved wrong. I will check again with Apple.
12-01-2012

After a long discussion, I now understand what isArmed() is wrt. the menu "showing" and "focued" states. I still think that isArmed() might be a useful concept for menus to indicate that an item is drawn "blue" (can't say selected or confusion will ensue ...) but let's leave this for now. Here is the summary of "showing" and "focused" in case the concepts come up again: "I now understand what is going on wrt. the menu "blue" stage and "armed/focused/selected" and "showing". My confusion was around the fact that a menu is also a menu item. For example, on the native Mac menu bar, if you use the arrow keys to arrow around a menu, the items are "focused". If you stop on an item that has a "submenu" (an FX Menu), then the item is "blue" and "focused". If you use the right arrow key to "popup" the "submenu", then the item remains "blue" and changes to "showing" and a new item on the "submenu" becomes "focused". The thing that fooled me is that both states were "blue". "
12-01-2012

Here is the AWT/Swing code that does what is needed. Perhaps isArmed() could be added to MenuItem and that would be enough? http://java.net/projects/jemmy/sources/svn/content/trunk/AWT/Jemmy2/src/org/netbeans/jemmy/drivers/menus/AppleMenuDriver.java?rev=93
02-01-2012

If FX is going to support a native menu bar, the properties like Menu.isShowing() are going to need to be kept up to date with what is happening in the operating system. Did you have a particular list that you need? In an email thread, you talked about getting the selected menu item.
23-12-2011