![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/InputEvent.h>
Base class for user input events in a graphical user interface (GUI). More...
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.
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 KeyEvent * | asKeyEvent () const |
Convenience function to dynamic_cast this instance to a KeyEvent. | |
const MouseEvent * | asMouseEvent () const |
Convenience function to dynamic_cast this instance to a MouseEvent. | |
const TouchEvent * | asTouchEvent () const |
Convenience function to dynamic_cast this instance to a TouchEvent. | |
const ContextMenuEvent * | asContextMenuEvent () 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 LocalToGlobalCoordMapping & | localToGlobalMappingFunction () const |
Protected Attributes | |
Flags< KeyboardModifier > | m_modifiers = KeyboardModifier::None |
LocalToGlobalCoordMapping | m_localToGlobalMappingFunction |
|
strong |
Bitfield enumeration to describe modifier keys on the keyboard.
Control
and Meta
for MacOS where the Control modifier corresponds to the Command key and the Meta modifier to the Control keys.
|
explicit |
Constructor for the InputEvent base class.
modifiers | List of pressed keyboard modifier keys. |
mappingFunction | Optional 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. |
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.
|
inline |