Protected Attributes

Detailed Description

The Action class is used to represent an "action" that gets performed because of some event from the UI, such as clicking a menu item or button.

An Action also allows you to consolidate multiple event handlers for menu items, buttons, etc, and their associated code to update their UI state in relation to the application's state. An Action has one or more targets that get notified for update events. Any of these targets can also cause the action to be executed or "performed".

An example of how this might be useful:

Consider an application that has three UI elements, a button, a toolbar item, and a menu item. Clicking the menu item, toolbar item, or button all cause some change of state in the application. Without using actions, you would have to write 3 individual event handlers for the "click" events of the menu item, button, and toolbar item, as well as separate ui updating code. If you use an action, you simply add all three items as targets to the action, and then write a single handler that's attached to the action's Performed delegate, and another event handler that is attached to the action's Update delegate. The framework then takes care of the rest, and clicking the button, menu item, or toolbar item will all cause event handler attached to the action's Performed delegate to get called, and each UI element will in turn be updated as specified by event handler attached to the action's Update delegate.

Event Delegates for this class:

Update

Performed

Member Enumeration Documentation

anonymous enum

Enumerator:

UpdateEvent

This event type is used when the update method is invoked.

ActionPerformedEvent

This is used when an action event is fired.

AcceleratorChanged

This is used when the action's accelerator is changed, specifically by the method setAcceleratorKey().

If one already exists then it is removed. To ensure that any targets of this action are properly updated, the action creates a Event instance, sets it's event type to Action::AcceleratorChanged, loops through all it's targets, and then calls each target's handleEvent() method passing in the event instance. Targets should respond accordingly to this event if it makes sense.

If one already exists it is removed for this action item. The accelerator is assigned the key code and modifier mask passed in, and is given a default event handler which calls the action item's perform method. An action may have only one accelerator associated with it at any given time. Internally this method creates a new AcceleratorKey isntance and then calls the setAcceleratorKey( AcceleratorKey* ) method. See this method's documentation for more details.

This is called by a target (or the framework itself) to tell the action to fire off an update event to all the actions targets.

First an Update event is fired in order to let the application to set, in the event(s) handler(s) of this action, the desired state for the ActionEvent ( e.g. enabled or not, checked or not. Then the update ActionEvent is fired off to all the actions targets. The enabled state of the accelerator associated to this action, if any, is also updated accordingly.