docs » plugins.core.action.handler
A support class for handler handlers. It is not used directly, rather
it is a 'super class' that provides common functionality.
Instances of the class primarily need to provide functions for the following:
local handler = actionManager :addHandler (" foobar" )
:onChoices (function (choices ) ... end )
:onExecute (function (action ) ... end )
The choices added to the choices
should have the params
value set to a table
containing the details of the action to execute if the choice is selected.
Signature
plugins.core.action.handler.new(id, group) -> handler
Type
Constructor
Description
Creates a new handler with the specified ID.
Parameters
id
- The unique ID of the action handler.group
- The group the handler belongs to.label
- An optional label for the handler (over-riding a supplied i18n value)
Returns
The new action handler instance.
Signature
plugins.core.action.handler.cached <cp.prop: boolean>
Type
Field
Description
If set to true
(the default), any choices created will be cached until [reset] is called.
Signature
plugins.core.action.handler.choices <cp.prop: cp.choices; read-only>
Type
Field
Description
Provides cp.choices
instance for the handler. May be watched/monitored/etc.
Signature
plugins.core.action.handler:actionId(action) -> string
Type
Method
Description
Returns a string that can be used as a unique ID for the action details.
Signature
plugins.core.action.handler:execute(action) -> boolean
Type
Method
Description
Executes the action, based on values in the table.
Parameters
action
- A table of details about the action.
Returns
true
if the execution succeeded.
Signature
plugins.core.action.handler:group() -> string
Type
Method
Description
Returns the group for this handler.
Parameters
Returns
Signature
plugins.core.action.handler:id() -> string
Type
Method
Description
Returns the ID for this handler.
Parameters
Returns
Signature
plugins.core.action.handler:label() -> string
Type
Method
Description
Returns the label for this handler.
Parameters
Returns
Signature
plugins.core.action.handler:onActionId(actionFn) -> handler
Type
Method
Description
Configures a function to handle converting an action to unique ID.
Parameters
actionFn
- The function with a signature of function(action) -> string
Returns
Signature
plugins.core.action.handler:onChoices(choicesFn) -> handler
Type
Method
Description
Adds a callback function which will receive the cp.choices
instance to add
Parameters
choicesFn
- The function with the signature of function(choices) -> nothing
Returns
Signature
plugins.core.action.handler:onExecute(executeFn) -> handler
Type
Method
Description
Configures the function to call when a choice is executed. This will be passed
Parameters
executeFn
- The function to call when executing.
Returns
Signature
plugins.core.action.handler:reset([updateNow]) -> nil
Type
Method
Description
Resets the handler, clearing any cached result and requesting new ones.
Parameters
updateNow
- (optional) If true
, the choices will update immediately, otherwise they will update when the choices are next requested.
Returns