new wcMenu(container, options)
Parameters:
| Name | Type | Argument | Description |
|---|---|---|---|
container |
external:jQuery~Object | external:jQuery~Selector | external:domNode | The container element. | |
options |
wcMenu~Options |
<optional> |
Custom options. |
Methods
-
functionaddOption(categoryName, name, options) > Boolean -
Adds a new file menu and/or toolbar option.
Parameters:
Name Type Description categoryNameString The top level category to place this option in the menu. nameString The name for the option. optionswcMenu~MenuOptions Custom options for the menu item. Returns: Boolean
Success or failure.
-
functionaddSpacer(categoryName, name) > Boolean -
Adds a spacer to a menu list.
Parameters:
Name Type Description categoryNameString The top level category to place this spacer in the menu. nameNumber The name of the menu option, the spacer is inserted after. Returns: Boolean
Success or failure.
-
functionaddToolbarSpacer(categoryName, name) > Boolean -
Adds a spacer to the toolbar.
Parameters:
Name Type Description categoryNameString The top level category to place this spacer in the menu. nameNumber The name of the toolbar option, the spacer is inserted after. Returns: Boolean
Success or failure.
-
functionoptionCondition(categoryName, name, description) > Boolean -
Replaces the description for an existing option.
Parameters:
Name Type Argument Description categoryNameString The top level category of the option. nameString The name of the option. descriptionString | wcMenu~MenuDescriptionFunc <optional>
The description to show as a tooltip for this option. Returns: Boolean
Success or failure.
-
functionoptionCondition(categoryName, name, condition) > Boolean -
Replaces the condition for an existing option.
Parameters:
Name Type Argument Description categoryNameString The top level category of the option. nameString The name of the option. conditionfunction <optional>
A function to call during the update to determine if the menu option should be enabled or disabled. Return false to disable the option. Returns: Boolean
Success or failure.
-
functionoptionDisplay(categoryName, name, display) > Boolean -
Replaces the display for an existing option.
Parameters:
Name Type Argument Description categoryNameString The top level category of the option. nameString The name of the option. displaywcMenu~MenuDisplayFunc <optional>
A function that returns the display text that should be shown on the menu option item. If not supplied, the default menu name will be applied. Returns: Boolean
Success or failure.
-
functionoptionHotkeys(categoryName, name) > Boolean -
Replaces the hotkeys for an existing option.
Parameters:
Name Type Description categoryNameString The top level category of the option. nameString The name of the option. Returns: Boolean
Success or failure.
-
functionoptionIcon(categoryName, name, icon) > Boolean -
Replaces the icon for an existing option.
Parameters:
Name Type Argument Description categoryNameString The top level category of the option. nameString The name of the option. iconString | wcMenu~MenuIconFunc <optional>
A classname to apply as an icon for the option. If this is a function, it will be called during the update call and should return the icon class. Returns: Boolean
Success or failure.
-
functionoptionOnActivated(categoryName, name, onActivated) > Boolean -
Replaces the activation handler for an existing option.
Parameters:
Name Type Description categoryNameString The top level category of the option. nameString The name of the option. onActivatedwcMenu~OnActivation A handler to call when the option is activated. Returns: Boolean
Success or failure.
-
functionoptionToggle(categoryName, name, toggle) > Boolean -
Replaces the toggle function for an existing option.
Parameters:
Name Type Argument Description categoryNameString The top level category of the option. nameString The name of the option. togglewcMenu~MenuToggleFunc <optional>
A function that returns the toggle state of the menu option item. If not supplied, option will no longer toggle. Returns: Boolean
Success or failure.
-
functionremoveOption(categoryName, name, options) > Boolean -
Removes an existing file menu and/or toolbar option.
Parameters:
Name Type Description categoryNameString The top level category to place this option in the menu. nameString The name to display for the option. optionswcMenu~MenuOptions Custom options for the menu item. Returns: Boolean
Success or failure.
-
functionremoveSpacer(categoryName, name) > Boolean -
Removes an existing spacer from the menu list.
Parameters:
Name Type Description categoryNameString The top level category where this spacer can be found. nameNumber The name of the menu option to remove the spacer from. Returns: Boolean
Success or failure.
-
functionremoveToolbarSpacer(categoryName, name) > Boolean -
Removes an existing spacer from the toolbar.
Parameters:
Name Type Description categoryNameString The top level category where this spacer can be found. nameNumber The name of the toolbar option to remove the spacer from. Returns: Boolean
Success or failure.
-
functionupdate() -
Updates dynamic menus, if you've assigned options.manualUpdate = false, then you will need to call this yourself.
-
functionversion(tag) > String -
Gets, or Sets the version tag to display in the right margin of the menu bar.
Parameters:
Name Type Argument Description tagString <optional>
The version tag. Returns: String
Type Definitions
-
inner typedef varMenuOptions -
Custom options for a menu option.
Type: Object
- Source: menu.jsdoc, line 44
Properties:
Name Type Argument Description togglewcMenu~MenuToggleFunc <optional>
A function that returns the current toggle state of the option. displaywcMenu~MenuDisplayFunc <optional>
A function that returns the display text that should be shown on the menu option item. If not supplied, the default menu name will be applied. iconString | wcMenu~MenuIconFunc <optional>
A classname to apply as an icon for the option. If this is a function, it will be called during the update call and should return the icon class. descriptionString | wcMenu~MenuDescriptionFunc <optional>
The description to show as a tooltip for this option. itemIndexNumber <optional>
An insertion index to insert the item within the menu category, default is to append to the end. categoryIndexNumber <optional>
If this creates a new category, it will be inserted at this index in the top level menu. toolbarIndexBoolean <optional>
If supplied, creates a toolbar button for this option and inserts it in the tab bar at the specified index. -1 will append it to the end. hotkeysString <optional>
A string that describes hotkeys for your control, the format is 'Ctrl+Z' or 'Alt+Shift+L,Shift+L' for multiple. conditionfunction <optional>
A function to call during the update to determine if the menu option should be enabled or disabled. Return false to disable the option. -
inner typedef varOptions -
Menu options.
Type: Object
- Source: menu.jsdoc, line 1
Properties:
Name Type Argument Default Description outerexternal:jQuery~Object | external:jQuery~Selector | external:domNode <optional>
'body' The outer container element, this is your main container area for the entire window. dataObject <optional>
A custom data object that will be passed to all event handlers. manualUpdateBoolean <optional>
Set true if you want to handle the menu update yourself. versionString <optional>
A version tag to display in the right margin of the menu bar. -
inner typedef functionMenuDescriptionFunc(data) > String -
A callback that retrieves the description string for a menu option.
Parameters:
Name Type Description dataObject The custom data object from wcMenu~Options. Returns: String
- Source: menu.jsdoc, line 37
-
inner typedef functionMenuDisplayFunc(data) > String -
A callback that retrieves the display text for the menu option.
Parameters:
Name Type Description dataObject The custom data object from wcMenu~Options. Returns: String
- Source: menu.jsdoc, line 16
-
inner typedef functionMenuIconFunc(data) > String -
A callback that retrieves the icon class for a menu option.
Parameters:
Name Type Description dataObject The custom data object from wcMenu~Options. Returns: String
- Source: menu.jsdoc, line 30
-
inner typedef functionMenuToggleFunc(data) > String -
A callback that retrieves the current toggle state of the menu option.
Parameters:
Name Type Description dataObject The custom data object from wcMenu~Options. Returns: String
- Source: menu.jsdoc, line 23
-
inner typedef functionOnActivation(data) -
On click handler for menu and toolbar options.
Parameters:
Name Type Description dataObject The custom data object from wcMenu~Options. - Source: menu.jsdoc, line 10