ImFusion SDK 4.3
InputEvent Class Reference

#include <ImFusion/GUI/InputEvent.h>

Base class for user input events in a graphical user interface (GUI). More...

+ Inheritance diagram for InputEvent:

Detailed Description

Base class for user input events in a graphical user interface (GUI).

By design, all InputEvents are immutable to make reasoning over the program logic easier. In contrast to many other event messaging frameworks the back-channel for notifying a sender whether a receiver "accepted" an event and/or how it should continue propagation is not the event itself but the EventResult struct serving as return value of a handleInputEvent() function.

Note
All coordinates/positions held by an InputEvent are in the rendering coordinate system of the Display instance emitting the event. This means that the origin is in the lower left corner of the viewport, in the same fashion as done by OpenGL.
See also
InputEventHelpers

Public Types

enum class  KeyboardModifier {
  None = 0 , Shift = 1 << 0 , Control = 1 << 1 , Alt = 1 << 2 ,
  Meta = 1 << 3
}
 Bitfield enumeration to describe modifier keys on the keyboard. More...
 
using LocalToGlobalCoordMapping = std::function<vec2(const vec2&)>
 Typedef for a function to map from event coordinates to global coordinates if applicable.
 

Public Member Functions

 InputEvent (Flags< KeyboardModifier > modifiers, LocalToGlobalCoordMapping mappingFunction=nullptr)
 Constructor for the InputEvent base class.
 
const KeyEventasKeyEvent () const
 Convenience function to dynamic_cast this instance to a KeyEvent.
 
const MouseEventasMouseEvent () const
 Convenience function to dynamic_cast this instance to a MouseEvent.
 
const TouchEventasTouchEvent () const
 Convenience function to dynamic_cast this instance to a TouchEvent.
 
const ContextMenuEventasContextMenuEvent () const
 Convenience function to dynamic_cast this instance to a ContextMenuEvent.
 
const Flags< KeyboardModifier > & modifiers () const
 Returns the list of pressed keyboard modifier keys.
 
vec2 mapToGlobalCoord (const vec2 &localCoord) const
 Converts the given localCoord to the global coordinate system of the underlying windowing system if applicable.
 
const LocalToGlobalCoordMappinglocalToGlobalMappingFunction () const
 

Protected Attributes

Flags< KeyboardModifierm_modifiers = KeyboardModifier::None
 
LocalToGlobalCoordMapping m_localToGlobalMappingFunction
 

Member Enumeration Documentation

◆ KeyboardModifier

enum class KeyboardModifier
strong

Bitfield enumeration to describe modifier keys on the keyboard.

Note
According to the Apple Human Interface Guidelines the Command key is to be used for almost all keyboard shortcuts. All other platforms use the Control key instead. Therefore, this enumeration swaps the meaning of Control and Meta for MacOS where the Control modifier corresponds to the Command key and the Meta modifier to the Control keys.
Enumerator
None 

None of the modifier keys is pressed.

Shift 

Shift key is pressed.

Control 

Control key is pressed; except for MacOS: Command key is pressed.

Alt 

Alt key is pressed.

Meta 

Meta key is pressed; except for MacOS: Control key is pressed.

Constructor & Destructor Documentation

◆ InputEvent()

InputEvent ( Flags< KeyboardModifier > modifiers,
LocalToGlobalCoordMapping mappingFunction = nullptr )
explicit

Constructor for the InputEvent base class.

Parameters
modifiersList of pressed keyboard modifier keys.
mappingFunctionOptional mapping function used by mapToGlobalCoord() to convert event coordinates to global coordinates if the underlying windowing system supports it; mapToGlobalCoord() will use the identity function if empty.

Member Function Documentation

◆ mapToGlobalCoord()

vec2 mapToGlobalCoord ( const vec2 & localCoord) const

Converts the given localCoord to the global coordinate system of the underlying windowing system if applicable.

If the original source of the event does not support global coordinates it will return the input value unchanged.

Deprecated
This function is merely provided as a deprecation layer to make the Qt-based view framework work with the new ImFusion::GUI framework. Do not rely on this functionality in new code because it may be removed in the future.

◆ localToGlobalMappingFunction()

const LocalToGlobalCoordMapping & localToGlobalMappingFunction ( ) const
inline
Deprecated
This function is merely provided as a deprecation layer to make the Qt-based view framework work with the new ImFusion::GUI framework. Do not rely on this functionality in new code because it may be removed in the future.

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close