DarkRadiant EventManager

From The DarkMod Wiki
Revision as of 11:23, 12 January 2007 by Greebo (talk | contribs)
Jump to navigationJump to search

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.
  • 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