Magnum::Ui::KeyEvent class new in Git master

Key press or release event.

Constructors, destructors, conversion operators

KeyEvent(Nanoseconds time, Key key, Modifiers modifiers) explicit
Constructor.

Public functions

auto time() const -> Nanoseconds
Time at which the event happened.
auto key() const -> Key
Key that got pressed or released.
auto modifiers() const -> Modifiers
Active keyboard modifiers.
auto position() const -> Containers::Optional<Vector2>
Event position.
auto isCaptured() const -> bool
Whether the event is captured 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::KeyEvent::KeyEvent(Nanoseconds time, Key key, Modifiers modifiers) explicit

Constructor.

Parameters
time Time at which the event happened
key Key that got pressed or released
modifiers Active keyboard modifiers

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.

Containers::Optional<Vector2> Magnum::Ui::KeyEvent::position() const

Event position.

If the event was called on a AbstractUserInterface::currentFocusedNode(), returns Containers::NullOpt. Otherwise the node was picked based on pointer position from a preceding pointer press, release or move event, and the function returns a position relative to that node.

bool Magnum::Ui::KeyEvent::isCaptured() const

Whether the event is captured on a node.

If the event is called on a AbstractUserInterface::currentFocusedNode(), returns false. Otherwise returns true if AbstractUserInterface::currentCapturedNode() is the same as the node the event is called on, false otherwise. Unlike PointerEvent or PointerMoveEvent, key events don't have a possibility to modify the captured status.

bool Magnum::Ui::KeyEvent::isHovering() const

Whether the event is called on a node that's currently hovered.

Returns true if AbstractUserInterface::currentHoveredNode() is the same as the node the event is called on, false otherwise.

bool Magnum::Ui::KeyEvent::isFocused() const

Whether the event is called on a node that's currently focused.

Returns true if AbstractUserInterface::currentFocusedNode() is the same as the node the event is called on, 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.

bool Magnum::Ui::KeyEvent::isAccepted() const

Whether the event is accepted.

Implicitly false.

void Magnum::Ui::KeyEvent::setAccepted(bool accepted = true)

Set the event as accepted.

Once an event is accepted, it doesn't propagate further.