AWT. Action

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

Constructor

new Action(name, actionPerformed)

Action constructor

Parameters:
NameTypeDescription
namestring

The name of this Action

actionPerformedfunction

The callback to be triggered by this Action

Members

description :string

An optional description

Type:
  • string

enabled :boolean

Action status. true means enabled, false disabled

Type:
  • boolean

name :string

The action's name

Type:
  • string

Methods

actionPerformed(_thisAction, _event)

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

Parameters:
NameTypeDescription
_thisActionmodule:AWT.Action

Pointer to this Action object

_eventobject

The original action event that has originated this action

addStatusListener(listener)

Adds a status listener

Parameters:
NameTypeDescription
listenerfunction

The callback method to be called when the status of this
Action changes

processEvent(event)

This is the method to be passed to DOM event triggers

Parameters:
NameTypeDescription
eventobject

The event object passed by the DOM event trigger

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

removeStatusListener(listener)

Removes a previously registered status listener

Parameters:
NameTypeDescription
listenerfunction

The listener to be removed

setEnabled(enabled)

Enables or disables this action

Parameters:
NameTypeDescription
enabledboolean