RCP application menus in Mac OS

匆匆过客 提交于 2019-12-12 03:40:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!