ImFusion SDK 4.3
MouseEvent Class Referencefinal

#include <ImFusion/GUI/InputEvent.h>

Mouse events are triggered whenever the status of the mouse has changed wrt. More...

+ Inheritance diagram for MouseEvent:

Detailed Description

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:

  • button() should only be used for Press, Release, or DoubleClick events
  • wheelAngleDelta() should only be used for Wheel events.
  • For 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.
 
- Public Types inherited from InputEvent
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< ButtonallButtons () 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.
 
- Public Member Functions inherited from InputEvent
 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
 

Static Public Member Functions

static MouseEvent makeLeaveEvent ()
 Convenience factory function to create a MouseEvent of Type::Leave.
 

Additional Inherited Members

- Protected Attributes inherited from InputEvent
Flags< KeyboardModifierm_modifiers = KeyboardModifier::None
 
LocalToGlobalCoordMapping m_localToGlobalMappingFunction
 

Member Enumeration Documentation

◆ Type

enum class Type
strong

Enumeration of reasons for the event.

Enumerator
Press 

A mouse button was pressed.

Release 

A mouse button was released.

Move 

The mouse was moved.

Wheel 

The mouse wheel was rotated.

DoubleClick 

A double click event was registered.

Leave 

The mouse pointer left the region of the GUI element.

Constructor & Destructor Documentation

◆ MouseEvent()

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.

Parameters
typeReason for emitting this event.
sourceButtonThe button that caused a Press, Release, or DoubleClick event, should be None for all other types.
allButtonsThe state of all mouse buttons when emitting this event, should be None forLeave events.
positionPosition of the mouse pointer wrt. the main GUI element, should be zero forLeave events.
wheelAngleDeltaAngle in degrees that the mouse wheel was rotated in horizontal/vertical direction, should be zero for all event types except for Wheel.
modifiersList of pressed keyboard modifier keys, should be zero forLeave events.
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.

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