Dima
Dima

Reputation: 4128

RCP application menus in Mac OS

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)

Upvotes: 0

Views: 383

Answers (1)

greg-449
greg-449

Reputation: 111142

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.

Upvotes: 1

Related Questions