Namespace actions
Provides access to menu items.
To access the namespace, use require('actions')
.
The actions
namespace provides methods to work with Action
s.
Actions can be added to Content Studio's menus, and can also be assigned a shortcut
key combination.
When actions are invoked by the user, an event is emitted;
actions are also event emitters, and emit the action
event when invoked
by the user.
Constructor Attributes | Constructor Name and Description |
---|---|
Provides access to menu items.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
actions.addAction(action, where)
Adds an menuItem to the given menu with the Action.
|
<static> |
actions.createAction(name, accelerator)
Returns an Action instance with the given name and accelerator.
|
<static> |
actions.removeAction(action, menuName)
Removes the menu item associated with the Action from the given Content Studio menu.
|
Namespace Detail
actions
Provides access to menu items.
var actions = require('actions'); var hello = actions.createAction('Hello'); hello.on('action', function() { console.log('Hello there'); }); actions.add(hello, 'help');
Method Detail
<static>
actions.addAction(action, where)
Adds an menuItem to the given menu with the Action.
actions.addAction(doit, 'file');
- Parameters:
- {Action} action
- the action created earlier to add to the menu
- {String} where
- The name of the menu to which the action should be added. One of
file
,edit
,view
,tools
,plugins
orhelp
<static>
actions.createAction(name, accelerator)
Returns an Action instance with the given name and accelerator.
var doit = actions.createAction('Do it!', 'alt F2');
- Parameters:
- name
- the name of the action.
- accelerator
- the keyboard shortcut of the action.
<static>
actions.removeAction(action, menuName)
Removes the menu item associated with the Action from the given Content Studio menu. If no name is provided, the action will be removed from all menus.
actions.removeAction(doit, 'file');
- Parameters:
- {Action} action
- the Action used when creating the menu item
- {String} menuName
- optionally, the name of the menu from which to remove the action.