const CommandManager = brackets.getModule("command/CommandManager")Kind: global class
- Command
- new Command(name, id, commandFn, [options])
- .getID() ⇒
string - .execute() ⇒
$.Promise - .getEnabled() ⇒
boolean - .getOptions() ⇒
object - .setEnabled(enabled)
- .setChecked(checked)
- .getChecked() ⇒
boolean - .setName(name, htmlName)
- .getName() ⇒
string
Events:
- enabledStateChange
- checkedStateChange
- keyBindingAdded
- keyBindingRemoved
| Param | Type | Description |
|---|---|---|
| name | string |
text that will be displayed in the UI to represent command |
| id | string |
|
| commandFn | function |
the function that is called when the command is executed. TODO: where should this be triggered, The Command or Exports? |
| [options] |
Get command id
Kind: instance method of Command
Executes the command. Additional arguments are passed to the executing function
Kind: instance method of Command
Returns: $.Promise - a jQuery promise that will be resolved when the command completes.
Is command enabled?
Kind: instance method of Command
get the command options
Kind: instance method of Command
Sets enabled state of Command and dispatches "enabledStateChange" when the enabled state changes.
Kind: instance method of Command
| Param | Type |
|---|---|
| enabled | boolean |
Sets enabled state of Command and dispatches "checkedStateChange" when the enabled state changes.
Kind: instance method of Command
| Param | Type |
|---|---|
| checked | boolean |
Is command checked?
Kind: instance method of Command
Sets the name of the Command and dispatches "nameChange" so that UI that reflects the command name can update.
Note, a Command name can appear in either HTML or native UI so HTML tags should not be used. To add a Unicode character, use \uXXXX instead of an HTML entity.
Kind: instance method of Command
| Param | Type | Description |
|---|---|---|
| name | string |
|
| htmlName | string |
If set, this will be displayed in ui menus instead of the name given. Example: "Phoenix menu<i class='fa fa-car' style='margin-left: 4px;'></i>" |
Get command name
Kind: instance method of Command
Manages global application commands that can be called from menu items, key bindings, or subparts of the application.
This module dispatches these event(s):
- commandRegistered -- when a new command is registered
- beforeExecuteCommand -- before dispatching a command
Event triggered before command executes.
Keyboard shortcut trigger.
UI menu click trigger.
Other trigger types.
register(name, id, commandFn, [options]) ⇒ Command
Registers a global command.
Kind: global function
| Param | Type | Description |
|---|---|---|
| name | string |
text that will be displayed in the UI to represent command |
| id | string |
unique identifier for command. Core commands in Brackets use a simple command title as an id, for example "open.file". Extensions should use the following format: "author.myextension.mycommandname". For example, "lschmitt.csswizard.format.css". |
| commandFn | function |
the function to call when the command is executed. Any arguments passed to execute() (after the id) are passed as arguments to the function. If the function is asynchronous, it must return a jQuery promise that is resolved when the command completes. Otherwise, the CommandManager will assume it is synchronous, and return a promise that is already resolved. |
| [options] | Object |
|
| options.eventSource | boolean |
If set to true, the commandFn will be called with the first argument event with details about the source(invoker) as event.eventSource(one of the CommandManager.SOURCE_*) and event.sourceType(Eg. Ctrl-K) parameter. |
| options.htmlName | string |
If set, this will be displayed in ui menus instead of the name given. Example: "Phoenix menu<i class='fa fa-car' style='margin-left: 4px;'></i>" |
registerInternal(id, commandFn) ⇒ Command
Registers a global internal only command.
Kind: global function
| Param | Type | Description |
|---|---|---|
| id | string |
unique identifier for command. Core commands in Brackets use a simple command title as an id, for example "app.abort_quit". Extensions should use the following format: "author.myextension.mycommandname". For example, "lschmitt.csswizard.format.css". |
| commandFn | function |
the function to call when the command is executed. Any arguments passed to execute() (after the id) are passed as arguments to the function. If the function is asynchronous, it must return a jQuery promise that is resolved when the command completes. Otherwise, the CommandManager will assume it is synchronous, and return a promise that is already resolved. |
get(id) ⇒ Command
Retrieves a Command object by id
Kind: global function
| Param | Type |
|---|---|
| id | string |
Returns the ids of all registered commands
Looks up and runs a global command. Additional arguments are passed to the command.
Kind: global function
Returns: $.Promise - a jQuery promise that will be resolved when the command completes.
| Param | Type | Description |
|---|---|---|
| id | string |
The ID of the command to run. |