Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Special per-platform menu considerations

For many menu commands, convention dictates where these items will be placed. For instance, the Edit menu always starts with the Undo command if such a feature is available in the application, followed by Redo, Cut, Copy, Paste, and so forth.

Some menu items have specific common labels or locations where certain menu items would go that differ on each platform. For instance, on Windows, the menu item which exits the application is labeled "Exit" and is normally placed at the end of the File menu.

The Mac application menu

On the Macintosh, an extra menu exists beside the File menu; its name is the same as the name of the application. This menu contains a number of items that pertain to the application. For instance, this is the proper place to put the menu items which open the application preferences and which quit the application.

This can be accomplished by ensuring that certain common ids are set for the menu items that need to be placed on the application menu. On the Mac, these menu items will be moved onto the application menu, but on other platforms, they will be left in their original locations. This makes it easier to write the same XUL code for all platforms. Here is a list of the menu item ids which are automatically handled.

menu_FileQuitSeparator The separator just before the Quit/Exit item.
menu_FileQuitItem The item which exits the application.
menu_PrefsSeparator The separator just before the Preferences/Options item.
menu_preferences The item which opens the application preferences.
aboutSeparator The separator just before the About item.
aboutName The item which opens the about dialog for the application.
menu_mac_services A menu which provides system services.
menu_mac_hide_app Selecting this item will hide the application.
menu_mac_hide_others Selecting this item will hide all other applications except this one.
menu_mac_show_all Selecting this item will show the windows for all applications.
checkForUpdates The item that opens the Update dialog for the application, for applications that have one (such as SeaMonkey; Firefox does not have this item).

The last five items aren't normally used but are listed for completeness.

Here is an example:

<menubar>
  <menu label="Tools">
    <menupopup>
      <menuitem label="Spell Check"/>
      <menuitem id="menu_preferences" label="Preferences"
                oncommand="window.openDialog('options.xul', '_new', 'chrome');"/>
    </menupopup>
  </menu>
</menubar>

Image:Popupguide-specialmenubar.png

This menu item will be placed on the application menu on the Macintosh but left in the Tools menu on other platforms. When moved to the application menu, the label and shortcut keys are overridden by platform conventions. However, regardless of the platform, the command event will be fired on the menu item when it is activated by the user.

Notes for Firefox extension developers

On the Mac, some elements, once moved to the Application menu, are no longer accessible from XUL overlays or from JavaScript injected into browser.xul.  For example, using document.getElementById() for the Quit menu item returns the hidden item that still sits in the File menu.  To change these items in Firefox, overlay hiddenWindow.xul instead.

Document Tags and Contributors

 Contributors to this page: Sheppy, ttaubert, Glazou, Swiney, SylvainPasche, MarkFinkle, Shoot, Mgjbot, Enn
 Last updated by: Sheppy,