Menu Object

The Menu object represents a single menu and allows more detailed inspection of menu states.

Menu Type Commands

Menu.rootMenus v2.0.5

Returns an array of Menu objects, one for each menu on the main application menu bar, eg: this array will contain a File menu, Edit menu, etc.

Menu.menuAtPath menuPath v2.0.5

Return the Menu object from the main menu with the given full menu path, path fragment, or title. Some examples which all access the same menu:

$menu = Menu.menuAtPath(":Edit:Select:Select All") # full path

$menu = Menu.menuAtPath("Select:Select All") # path fragment

$menu = Menu.menuAtPath("Select All") # title

If no such menu exists, returns the @undefined value. 

Menu.existsAtPath menuPath v2.0.5

Returns @true if a menu with the given path exists, otherwise returns @false. See the command Menu.menuAtPath for more on the menu path.

Menu.activateAtPath menuPath v2.0.5

Activates the menu with the given path just as if the user had chosen it. See the command Menu.menuAtPath for more on the menu path. This command is equivalent to the following:

$menu = Menu.menuAtPath($menuPath)

If $menu

$menu.activate

End

This command returns @true if the menu exists and could be activated.

Menu.contextualMenus v2.0.5

Returns an array of Menu objects, one for each menu that would appear if the user showed the contextual menu for the active selection in the frontmost document.

Menu.contextualMenuAtPath menuPath v2.0.5

Return the Menu object from the contextual menu with the given full path, path fragment, or title. If no such menu exists, returns the @undefined value.

Menu Object Properties

.title v2.0.5

Returns the title of the menu as a string. Read-only.

.path v2.0.7

Returns the full path the menu as a string. Read-only.

.enabled v2.0.5

Returns @true if the menu is enabled, or returns @false if disabled. Read-only.

.state v2.0.5

Returns an integer that describes what state the menu shows beside it.

Menu Shows

Returns

State

bold-on.png

1

The menu is checked.

bold-mixed.png

-1

The menu state is mixed.

bold-off.png

0

Neither checked nor mixed.

Note: for performance reasons the menu state may not be exactly calculated. If a large amount of text is selected, or there are many noncontiguous selections, only some subset of the selected text may be inspected.

As of Pro v2.1.5 this property is no longer read-only and can be set to either 0 or 1. Changing the menu’s state property behaves just like using the Set Menu State command.

.shortcutString v2.0.5

Returns keyboard shortcut for the menu as a string that does not show relevant modifier keys or proper capitalization. For example, the default shortcut for the menu File > Open would return just "o". Read-only.

.shortcutDisplayString v2.0.5

Returns a user-displayable keyboard shortcut for the menu as a string. For example, the default shortcut for the menu File > Save As would return "⇧⌘S". Read-only.

.submenus v2.0.5

Returns an array of Menu objects, one for each that are nested inside this menu. For example, the File menu has the submenus New, Open, Save, etc. Read-only.

Menu Object Commands

.activate v2.0.5

Activates the menu just as if the user had chosen it. For regular menus (eg: Bold) this triggers the menu command for the frontmost document. For menus that house submenus (eg: File), this will display the menu as a popup at the current mouse cursor location.


Previous Chapter
Menu Commands
<<  index  >>
 
Next Chapter
Files