class new in Git master
#include <Magnum/Ui/Event.h>
PointerEvent Pointer press or release event.
Constructors, destructors, conversion operators
- PointerEvent(Nanoseconds time, Pointer type) explicit
- Constructor.
Public functions
- auto time() const -> Nanoseconds
- Time at which the event happened.
- auto type() const -> Pointer
- Pointer type that got pressed or released.
- auto position() const -> Vector2
- Event position.
- auto isCaptured() const -> bool
- Whether the event is captured on a node.
- void setCaptured(bool captured)
- Set whether to capture the event on a node.
- auto isHovering() const -> bool
- Whether the event is called on a node that's currently hovered.
- auto isFocused() const -> bool
- Whether the event is called on a node that's currently focused.
- auto isAccepted() const -> bool
- Whether the event is accepted.
- void setAccepted(bool accepted = true)
- Set the event as accepted.
Function documentation
Magnum:: Ui:: PointerEvent:: PointerEvent(Nanoseconds time,
Pointer type) explicit
Constructor.
Parameters | |
---|---|
time | Time at which the event happened |
type | Pointer type that got pressed or released |
The time
may get used for UI animations. A default-constructed value causes an animation play time to be in the past, thus immediately transitioning to a stopped state. The position, capture and hover properties are set from AbstractUserInterface event handler internals.
bool Magnum:: Ui:: PointerEvent:: isCaptured() const
Whether the event is captured on a node.
On a press event is always implicitly true
, on a release event is true
only if the event happens on a captured node.
void Magnum:: Ui:: PointerEvent:: setCaptured(bool captured)
Set whether to capture the event on a node.
By default, after a pointer press event, a node captures all following pointer and key events until and including a pointer release, even if they happen outside of the node area.
If capture is disabled, the events are always sent to the actual node under the pointer. Which means that for example a node can receive a pointer press event without a corresponding release later, or a release alone.
Calling this function only makes sense on a pointer press event, it has no effect on a pointer release event or a tap or click event.
bool Magnum:: Ui:: PointerEvent:: isHovering() const
Whether the event is called on a node that's currently hovered.
Returns true
if AbstractUserInterface::false
otherwise. In particular, is false
for a press or release event that happened without a preceding move on given node, is also false
if a release event happens outside of a captured node.
Note that even if this function returns true
, the event handler still controls whether the pointer is actually treated as being in an active area of the node by either accepting the event or not accepting it and letting it potentially fall through to other nodes.
bool Magnum:: Ui:: PointerEvent:: isFocused() const
Whether the event is called on a node that's currently focused.
Returns true
if AbstractUserInterface::false
otherwise. Unlike isHovering(), returns true
also if the actual pointer position is outside of the area of the node the event is called on, for example in case of an event capture.
void Magnum:: Ui:: PointerEvent:: setAccepted(bool accepted = true)
Set the event as accepted.
Once an event is accepted, it doesn't propagate further.