问题
I am struggling to figure out how RCP applications on Mac OS work with "About" and "Preferences" actions. I create them with ActionFactory and place them to relevant file menus. Works fine everywhere. However, on Mac OS those actions get placed into application menu by something which knows better where to put other peoples good actions. But of course they don't work.. Any idea why?
(eclipse target platform 3.7, OSX - the latest El Capitan)
回答1:
For the 3.x style action bar advisor add the menu item in the normal place but use an ActionContributionItem
and set the menu item in be invisible on the Mac:
So for Quit something like:
IWorkbenchAction quitAction = ActionFactory.QUIT.create(window);
register(quitAction);
ActionContributionItem quitItem = new ActionContributionItem(quitAction);
quitItem.setVisible(!Util.isMac());
menu.add(quitItem);
'About' and 'Preferences' can also be specified like this.
Util
is org.eclipse.jface.util.Util
.
Eclipse will find these items and move them to the correct place.
来源:https://stackoverflow.com/questions/36681543/rcp-application-menus-in-mac-os