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.

API Overview

API Documentation

Constructors

new

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.
Returns
  • * The new action handler instance.

Fields

cached

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.

choices

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.

Methods

actionId

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.

execute

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.

group

Signature plugins.core.action.handler:group() -> string
Type Method
Description Returns the group for this handler.
Parameters
  • * None
Returns
  • * Group as string.

id

Signature plugins.core.action.handler:id() -> string
Type Method
Description Returns the ID for this handler.
Parameters
  • * None
Returns
  • * The ID string.

onActionId

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
  • * This action handler.

onChoices

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
  • * This action handler.

onExecute

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
  • * This action handler.

reset

Signature plugins.core.action.handler:reset() -> nil
Type Method
Description Resets the handler, clearing any cached result and requesting new ones.
Parameters
  • * None
Returns
  • * Nothing

results matching ""

    No results matching ""