Skip to content

Menu API

Daniel Whitcomb edited this page May 15, 2016 · 1 revision

#Monarch Menu API Monarch allows developers to easily define the menu structure for their web application and display it in OS X's menu bar when their application is opened as a Monarch Dynamic Application.

##Spec The API currently only involves two HTML tags. These tags are created in a tree structure, just a menu layout can be modeled.

###mdamenu mdamenu tags define menus and submenus. They should be nested together to create a menu tree. All trees should at least have a depth of 2. The root tag of the app's menu must be an mdamenu.

####Attributes title - The displayed name of the menu or submenu. For example: <mdamenu title="File">...</mdamenu>. If the root element is given a title, it will not be displayed.

app - Add this attribute to the mdamenu element which represents the menu item that will display the name of your application. For example, <mdamenu title="Monarch" app> ... </mdamenu>. There always needs to be a mdamenu element that has an app attribute, if there is not, any custom menus will not show.

###mdamenuitem mdamenuitem tags define actionable endpoints in your menu. They are the leaves of the menu tree and should never have child elements. These tags can support JavaScript execution when selected.

####Attributes title - The display name of the menu item. No two mdamenuitem elements may have the same title. Example: <mdamenuitem title="Save As ..."></mdamenuitem>.

action - Assigned a string of JavaScript to this attribute to have it be executed within your app's context when it is selected. Accessing JavaScript functions will work regardless of their loading order.

##Default Menus Apps will always have a 4 submenus on their top bar regardless of the presence of a MDA Menu. They are, in order:

1.app_name

2.File

3.Edit

4.Window

Each menu also has one to many default items which perform basic features like closing the app in the File menu, or copy/cut/paste in the Edit menu. While developers may not remove these items, they can add additional submenus or items to them. By creating a mdamenu element on the top level with the same title as a default menu, any mdamenu or mdamenuitem elements within it will be displayed above the default child menu items.

##Examples ###Basic Menu

Clone this wiki locally