Action

Source: AWT.js:1779

This class encapsulates actions that can be linked to buttons, menus and other active objects


Constructor

new Action(name: string, actionPerformed: function): Action

Action constructor

Parameters

  • name (string) — The name of this Action
  • actionPerformed (function) — The callback to be triggered by this Action

Instance Methods

actionPerformed(_thisAction: module:AWT.Action, _event: object)

Here is where subclasses must define the callback to be triggered when
this Action object is called

Parameters

  • _thisAction (module:AWT.Action) — Pointer to this Action object
  • _event (object) — The original action event that has originated this action

processEvent(event: object)

This is the method to be passed to DOM event triggers

Parameters

  • event (object) — The event object passed by the DOM event trigger

Example

CODE
<p>const myFunc = () =&gt; { alert('Hello!') }<br>
const myAction = new Action('hello', myFunc)<br>
$( &quot;#foo&quot; ).on( &quot;click&quot;, myAction.processEvent)</p>

addStatusListener(listener: function)

Adds a status listener

Parameters

  • listener (function) — The callback method to be called when the status of this
    Action changes

removeStatusListener(listener: function)

Removes a previously registered status listener

Parameters

  • listener (function) — The listener to be removed

setEnabled(enabled: boolean)

Enables or disables this action

Parameters

  • enabled (boolean)

Instance Fields

name: string

The action's name

description: string

An optional description

enabled: boolean

Action status. true means enabled, false disabled