RapaGUI events are handled in the very same way as normal Hollywood events.
This means that you just have to pass a callback function to Hollywood's
InstallEventHandler()
function and whenever a RapaGUI event is triggered,
your callback function will be called.
Here is an example how to install a RapaGUI event callback:
InstallEventHandler({RapaGUI = p_EventHandler}) |
Whenever an event occurs, RapaGUI will then call p_EventHandler()
with a table as parameter. The table will have the following fields
initialized:
Action:
Class:
Attribute:
ID:
TriggerValue:
MOAIUserData:
NotifyData:
On top of that it is also necessary to tell RapaGUI which events you would like to receive. Only events you explicitly request to receive are passed to your event callback to minimize overhead. An exception are button, toolbar button and menu item events. They are passed to your event callback even if you haven't requested them. The reason for this design choice is that normally all of these events need to be individually handled because the user expects something to happen when pressing a button.
All RapaGUI events are coupled to attributes of MOAI objects. The next section describes this in detail.