DarkRadiant EventManager: Difference between revisions
No edit summary |
No edit summary |
||
Line 10: | Line 10: | ||
* '''Command''' - this is a single-fire event that calls a function upon "KeyDown". Compatible widgets: GtkMenuItem, GtkToolButton | * '''Command''' - this is a single-fire event that calls a function upon "KeyDown". Compatible widgets: GtkMenuItem, GtkToolButton | ||
* '''Toggle''' - this is an event that has an internal bool state, that gets inverted on "KeyDown". Compatible widgets: GtkCheckMenuItem, GtkToggleToolButton. | * '''Toggle''' - this is an event that has an internal bool state, that gets inverted on "KeyDown". Compatible widgets: GtkCheckMenuItem, GtkToggleToolButton. | ||
* '''RegistryToggle''' - use this if you want the Event to invert a boolean value (i.e. "0"/"1") in the XMLRegistry. This event doesn't require a callback upon creation (only the event name and the registry key), as the change of the connected RegistryKey can be catched by implementing a RegistryKeyObserver class (or letting a class derive from RegistryKeyObserver). There are some examples in the GlobalXYWnd or the CameraSettings class to see how a RegistryKeyObserver can be implemented. As a RegistryToggle derives from the Toggle event, it can of course be connected to the same GtkWidgets. | |||
* '''KeyEvent''' - this is an event that catches both "KeyDown" and "KeyUp" of the according Accelerator and calls the connected callback functions. Use this if your class needs to implement a custom key handler (an example is the Camera Window in free-look mode). | * '''KeyEvent''' - this is an event that catches both "KeyDown" and "KeyUp" of the according Accelerator and calls the connected callback functions. Use this if your class needs to implement a custom key handler (an example is the Camera Window in free-look mode). | ||
== Accelerators == | == Accelerators == |
Revision as of 11:28, 12 January 2007
The EventManager plugin provides methods to define events and connect them to (member) functions that are called upon connect. This document is WIP.
Connecting Widgets
The events can be connected to certain GtkWidgets (like GtkMenuItems, GtkCheckMenuItems and GtkToolButtons/GtkToggleToolButtons). The events recognise the supported widet types and connect the callbacks automatically. For example, a "Toggle" event can of course be connected to a GtkCheckMenuItem or a GtkToggleToolButton, whereas a "Command" event cannot (connect it to a GtkMenuItem instead).
Event Types
The interface of an event (IEvent) is defined in ieventmanager.h. Events have to be created via the EventManager interface methods (e.g. addCommand(), addToggle(), addRegistryToggle() and so on). Each command can be enabled and disabled (enableEvent(), disableEvent()).
- (Event) - this is the basic, empty implementation of an event. It is used internally by the EventManager only.
- Command - this is a single-fire event that calls a function upon "KeyDown". Compatible widgets: GtkMenuItem, GtkToolButton
- Toggle - this is an event that has an internal bool state, that gets inverted on "KeyDown". Compatible widgets: GtkCheckMenuItem, GtkToggleToolButton.
- RegistryToggle - use this if you want the Event to invert a boolean value (i.e. "0"/"1") in the XMLRegistry. This event doesn't require a callback upon creation (only the event name and the registry key), as the change of the connected RegistryKey can be catched by implementing a RegistryKeyObserver class (or letting a class derive from RegistryKeyObserver). There are some examples in the GlobalXYWnd or the CameraSettings class to see how a RegistryKeyObserver can be implemented. As a RegistryToggle derives from the Toggle event, it can of course be connected to the same GtkWidgets.
- KeyEvent - this is an event that catches both "KeyDown" and "KeyUp" of the according Accelerator and calls the connected callback functions. Use this if your class needs to implement a custom key handler (an example is the Camera Window in free-look mode).