docs » cp.commands.command
Commands Module.
- Fields - Variables which can only be accessed from an object returned by a constructor
- isActive
- isEnabled
- Methods - API calls which can only be made on an object returned by a constructor
- action
- activated
- activatedBy
- addShortcut
- deleteShortcuts
- disable
- enable
- getAction
- getFirstShortcut
- getGroup
- getImage
- getShortcuts
- getSubtitle
- getTitle
- groupedBy
- hasAction
- id
- image
- new
- parent
- pressed
- released
- repeated
- setShortcuts
- subtitled
- titled
- whenActivated
- whenPressed
- whenReleased
- whenRepeated
| Signature | cp.commands.command.isActive <cp.prop: boolean; read-only> |
|---|---|
| Type | Field |
| Description | Indicates if the command is active. To be active, both the command and the group it belongs to must be enabled. |
| Signature | cp.commands.command.isEnabled <cp.prop: boolean> |
|---|---|
| Type | Field |
| Description | If set to true, the command is enabled. |
| Signature | cp.commands.command:action(getFn, setFn) -> command |
|---|---|
| Type | Method |
| Description | Sets the action get and set callbacks for a specific command. |
| Parameters |
|
| Returns |
|
| Notes |
|
| Signature | cp.commands.command:activated(repeats) -> command |
|---|---|
| Type | Method |
| Description | Executes the 'pressed', then 'repeated', then 'released' functions, if present. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:activatedBy([modifiers,] [keyCode]) -> command/modifier |
|---|---|
| Type | Method |
| Description | Specifies that the command is activated by pressing a key combination. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:addShortcut(newShortcut) -> command |
|---|---|
| Type | Method |
| Description | Adds the specified shortcut to the command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:deleteShortcuts() -> command |
|---|---|
| Type | Method |
| Description | Sets the function that will be called when the command key combo is pressed. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:disable() -> cp.commands.command |
|---|---|
| Type | Method |
| Description | Disables the command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:enable() -> cp.commands.command |
|---|---|
| Type | Method |
| Description | Enables the command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getAction() -> function, function |
|---|---|
| Type | Method |
| Description | Gets the action get and set callbacks for a specific command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getFirstShortcut() -> command |
|---|---|
| Type | Method |
| Description | Returns the first shortcut, or nil if none have been registered. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getGroup() -> string |
|---|---|
| Type | Method |
| Description | Returns the group ID for the command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getImage() -> hs.image object |
|---|---|
| Type | Method |
| Description | Returns the current image. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getShortcuts() -> command |
|---|---|
| Type | Method |
| Description | Returns the set of shortcuts assigned to this command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getSubtitle() -> string |
|---|---|
| Type | Method |
| Description | Returns the current subtitle, based on either the set subtitle, or the "_subtitle" value in the I18N files. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:getTitle() -> string |
|---|---|
| Type | Method |
| Description | Returns the command title in the current language, if availalbe. If not, the ID is returned. |
| Parameters |
|
| Signature | cp.commands.command:groupedBy(group) -> cp.commands.command |
|---|---|
| Type | Method |
| Description | Specifies that the command is grouped by a specific value. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:hasAction() -> boolean |
|---|---|
| Type | Method |
| Description | Gets whether or not any action callbacks have been assigned. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:id() -> string |
|---|---|
| Type | Method |
| Description | Returns the ID for this command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:image(img) -> cp.commands.command |
|---|---|
| Type | Method |
| Description | Sets the specified image and returns the cp.commands.command instance. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command.new() -> command |
|---|---|
| Type | Method |
| Description | Creates a new command, which can have keyboard shortcuts assigned to it. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:parent() -> cp.commands |
|---|---|
| Type | Method |
| Description | Returns the parent command group. |
| Parameters |
|
| Signature | cp.commands.command:pressed() -> command |
|---|---|
| Type | Method |
| Description | Executes the 'pressed' function, if present. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:released() -> command |
|---|---|
| Type | Method |
| Description | Executes the 'released' function, if present. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:repeated(repeats) -> command |
|---|---|
| Type | Method |
| Description | Executes the 'repeated' function, if present. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:setShortcuts(shortcuts) -> command |
|---|---|
| Type | Method |
| Description | Deletes any existing shortcuts and applies the new set of shortcuts in the table. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:subtitled(subtitle) -> cp.commands.command |
|---|---|
| Type | Method |
| Description | Sets the specified subtitle and returns the cp.commands.command instance. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:titled(title) -> command |
|---|---|
| Type | Method |
| Description | Applies the provided human-readable title to the command. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:whenActivated(activatedFn) -> command |
|---|---|
| Type | Method |
| Description | Sets the function that will be called when the command is activated. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:whenPressed(pressedFn) -> command |
|---|---|
| Type | Method |
| Description | Sets the function that will be called when the command key combo is pressed. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:whenReleased(releasedFn) -> command |
|---|---|
| Type | Method |
| Description | Sets the function that will be called when the command key combo is released. |
| Parameters |
|
| Returns |
|
| Signature | cp.commands.command:whenRepeated(repeatedFn) -> command |
|---|---|
| Type | Method |
| Description | Sets the function that will be called when the command key combo is repeated. |
| Parameters |
|
| Returns |
|