Table of Contents
The TBX event system allows you to handle the events generated by the toolbox and the RISC OS WIMP. For most events you add and remove listeners for the particular event on the C++ object that you wish to detect the event for. This means that you can associate multiple actions to be run when an event occurs. When an event occurs a method in the listener is called and (in most cases) an object containing information on the event is passed in the call. Although most events are passed on to all their listeners, there are a few where a parameter in the passed event information can be set to stop this.
The information for the event listeners is help separately from any C++ object/gadget/menu item class instance that has been created and is not affected by these being deleted or going out of scope. All event listeners are automatically removed when the underlying toolbox object that the events are on is destroyed.
All event listening routines are given a pointer to the C++ class instance that handles the event, so it is important that the handler class is not deleted before the event has been removed.
These are the default events generated by the underlying toolbox object/gadget.
They are caught in a tbx application by adding a listener for the specific event to the object/gadget they apply to.
Example 5.1. To add a changed listener to a writeable field w
w.add_text_changed_listener(&my_listener);The my_listener object is derived from a TextChangedListener and has its text_changed member called when the writeable field text changes.
You can add multiple listeners to the same event.
Note: The object/gadget must be set to deliver the event in the toolbox resource file for the listener to be called.