![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GUI/InputEvent.h>
Mouse events are triggered whenever the status of the mouse has changed wrt. More...
Mouse events are triggered whenever the status of the mouse has changed wrt.
the receiving GUI element.
A mouse event can be sourced from many different origins which are enumerated in Type. Not all of the members/properties of a MouseEvent make sense for all the types:
Press
, Release
, or DoubleClick
eventsWheel
events.Leave
events you should not use any of the members/properties. Leave events are special in this regard since they are only meant to notify the receiver that the mouse has left the boundaries of the receiver (once this is the case it will usually no longer receive any other mouse events and would otherwise not be capable of observing this).Note that button() and allButtons() have different meanings even though they are named similarly: the former indicates which single mouse button triggered an event while the latter indicates which mouse buttons are pressed down when the event was emitted. This difference is particularly important for the Release
event where the released mouse button is stored in button() but not in allButtons() (because it was just released).
The data type of wheelAngleDelta is two-dimensional since many windowing systems support both horizontal and vertical scroll events. The traditional 1D mouse wheel used for scrolling vertically is mapped to the Y axis of the vec2. Some mice allow the user to tilt the wheel to perform horizontal scrolling (and many touchpads support a horizontal scrolling gesture) which will be mapped to the X axis of the vec2.
Public Types | |
enum class | Type { Press , Release , Move , Wheel , DoubleClick , Leave } |
Enumeration of reasons for the event. More... | |
enum class | Button { None = 0 , Left = 1 << 0 , Middle = 1 << 1 , Right = 1 << 2 } |
Enumeration of named mouse buttons. | |
![]() | |
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 | |
MouseEvent (Type type, Button sourceButton, Flags< Button > allButtons, const vec2 &position, const vec2 &wheelAngleDelta=vec2::Zero(), Flags< KeyboardModifier > modifiers=KeyboardModifier::None, LocalToGlobalCoordMapping mappingFunction=nullptr) | |
Constructor for a MouseEvent. | |
Type | type () const |
Returns the reason for emitting this event. | |
Button | button () const |
Returns the button that caused a Press , Release , or DoubleClick event; do not use for other events. | |
Flags< Button > | allButtons () const |
Returns the state of all mouse buttons when emitting this event; do not use for Leave events. | |
const vec2 & | position () const |
Returns the position of the mouse pointer wrt. the main GUI element; do not use for Leave events. | |
const vec2 & | wheelAngleDelta () const |
Returns the angle in degrees that the mouse wheel was rotated in horizontal/vertical direction; use only for Wheel events. | |
![]() | |
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 |
Static Public Member Functions | |
static MouseEvent | makeLeaveEvent () |
Convenience factory function to create a MouseEvent of Type::Leave. | |
Additional Inherited Members | |
![]() | |
Flags< KeyboardModifier > | m_modifiers = KeyboardModifier::None |
LocalToGlobalCoordMapping | m_localToGlobalMappingFunction |
|
strong |
MouseEvent | ( | Type | type, |
Button | sourceButton, | ||
Flags< Button > | allButtons, | ||
const vec2 & | position, | ||
const vec2 & | wheelAngleDelta = vec2::Zero(), | ||
Flags< KeyboardModifier > | modifiers = KeyboardModifier::None, | ||
LocalToGlobalCoordMapping | mappingFunction = nullptr ) |
Constructor for a MouseEvent.
type | Reason for emitting this event. |
sourceButton | The button that caused a Press , Release , or DoubleClick event, should be None for all other types. |
allButtons | The state of all mouse buttons when emitting this event, should be None forLeave events. |
position | Position of the mouse pointer wrt. the main GUI element, should be zero forLeave events. |
wheelAngleDelta | Angle in degrees that the mouse wheel was rotated in horizontal/vertical direction, should be zero for all event types except for Wheel . |
modifiers | List of pressed keyboard modifier keys, should be zero forLeave events. |
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. |