Guiliani  Version 2.5 revision 6773 (build 33)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Input event handling

Page contents

Introduction

Guiliani has got its own input event handling mechanism. Input events that come in from the system are translated into Guiliani-specific events which are then handled by the event handler:

event_path.png

System events

System events can be any kind of events that a specific system generates, like input from devices like keyboard key presses, mouse movement or mouse button clicks. It may also be any other kind of event.

Input media

A Guiliani input medium is a class derived from CGUIInputMedia. The framework calls the method CGUIInputMedia::GetEvent in each main loop iteration. Each platform-specific specialization of this class is expected to receive events in its platform-specific way and create appropriate Guiliani events. These events are handed over to the event handler.

Guiliani events

Each Guiliani event is represented by a class derived from CGUIEvent. Currently Guiliani supports keyboard and mouse events. Therefore, any system event that ought to be handled by Guiliani has to be mapped to one of these by an input medium class.

The event handler

The event handler keeps track of the currently focused, pressed and highlighted objects. It examines the events created by an input medium in its CGUIEventHandler::HandleEvent method. Depending on the event and its attributes several actions are carried out:

  • Directional key presses are used to initiate focus changes (see Focusing).
  • Pressing a special action key results in a call to CGUIObject::DoClick on the currently focused object (same as a mouse button click).
  • Mouse movement may change the currently highlighted object.
  • Mouse movement while a mouse button is held down (mouse drag events) result in calls to CGUIObject::DoDrag.
  • Mouse button clicks may result in calls to the respective method calls (button down, button up, click, long click, double click).

Mappings from events to event handling slots

The following table shows which event handling method gets called in reaction to which input event.

Event handling method Guiliani event Description
CGUIBehaviour::DoClick ET_KEYDOWN (GK_ACTION) If a keyboard event containing the GK_ACTION identifier was triggered and the keypress was not handled in the CGUIBehaviour::DoKeyDown slot, CGUIBehaviour::DoClick will be called on the currently focussed object.
ET_LBUTTONUP If the left mouse button is released over the same object on which DoButtonDown was previously called, and the defined DragThreshold has not been exceeded, this results in DoClick being triggered.
ET_RBUTTONUP If the right mouse button is released over the same object on which DoButtonDown was previously called, and the defined DragThreshold has not been exceeded, this results in DoClick being triggered.
CGUIBehaviour::DoLongClick ET_LBUTTONDOWN Keeping the left button pressed on an object over a longer period of time will trigger a DoLongClick call on this object.
CGUIBehaviour::DoDoubleClick ET_LBUTTONUP If two clicks occur in a short period of time and the click position remained unchanged, a DoDoubleClick call is triggered upon releasing the button for the second time.
CGUIBehaviour::DoDrag ET_LBUTTONDOWN If the mouse is moved while a button is being pressed, a drag event is created on the object which was beneath the mouse pointer at the beginning of the dragging.
ET_MOUSEMOVE
CGUIBehaviour::DoDragEnd ET_LBUTTONUP If a mouse button is released at the end of a drag event, the object on which the dragging began receives a DoDragEnd call.
ET_RBUTTONUP
CGUIBehaviour::DoButtonDown ET_LBUTTONDOWN If a mouse button is pressed, the object beneath the mouse cursor receives a DoButtonDown call.
ET_RBUTTONDOWN
CGUIBehaviour::DoButtonUp ET_LBUTTONUP If a mouse button is released, the object beneath the mouse cursor receives a DoButtonUp call.
ET_RBUTTONUP
CGUIBehaviour::DoMouseMove ET_MOUSEMOVE Called if the mouse moves within an object's area without any buttons being pressed.
CGUIBehaviour::DoMouseEnter Called if the mouse enters an object's area.
CGUIBehaviour::DoMouseLeave Called if the mouse leaves an object's area.
CGUIBehaviour::DoChar ET_CHAR Called if a char event has been generated. In general this happens when a character key was pressed.
CGUIBehaviour::DoKeyDown ET_KEYDOWN Called if a key was pressed which generates a Guiliani key identifier (GK_...). In general this happens when a non-character key was pressed.
CGUIBehaviour::DoKeyUp ET_KEYUP Called if a key was released which generates a Guiliani key identifier (GK_...). In general this happens when a non-character key was released.
CGUIBehaviour::DoScrollUp ET_MOUSEWHEEL Called if the mousewheel was used in up direction.
CGUIBehaviour::DoScrollDown Called if the mousewheel was used in down direction.
CGUIBehaviour::DoScrollLeft Called if the mousewheel was used in up direction while a set key modifier was pressed. The key modifier can be set by using CGUIEventHandler::SetScrollModifiers.
CGUIBehaviour::DoScrollRight Called if the mousewheel was used in down direction while a set key modifier was pressed. The key modifier can be set by using CGUIEventHandler::SetScrollModifiers.
CGUIBehaviour::DoUserEvent any This will always be called on the currently focused object, for any type of event. As a matter of fact, DoUserEvent will also be called on the focused object in case of e.g. mouse events occuring somehwere else on the screen.

Exemplary sequence of events

The following table illustrates typical sequences of events within the GUI. Each example shown as a sketch in the left column is described in textual form within the right column. The Event Handling Slots printed in bold within the right column will be called on the given objects (A or B).

Event sequence Description
EventSequence1.png

User presses A and immediately releases the finger again.

A: DoButtonDown, DoButtonUp, DoClick

EventSequence2.png

User presses A, drags into B, and releases the finger.

A: DoButtonDown, DoDrag, DoDragEnd

B: DoButtonUp

EventSequence3.png

User presses A, drags outside, and enters A again before releasing the finger.

A: DoButtonDown, DoDrag, DoButtonUp , DoDragEnd

EventSequence4.png

User presses A, drags A along (e.g. in a ScrollView) and releases the finger over A at the new position.

A: DoButtonDown, DoDrag, DoButtonUp, DoDragEnd (if DragThreshold has been exceeded)

OR DoButtonDown, DoButtonUp, DoClick (if DragThreshold has NOT been exceeded)

Modal dialogs

The event handler can be instructed to make a CGUICompositeObject a modal dialog, resulting in input events only being directed to this object and its children.

Modal dialogs can be chained, which means that after one dialog has been made modal, another one on top of it can also be made modal. In this case, the first dialog does not receive any further events until the second modal dialog is closed.

Methods for influencing the modality of dialogs are: