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 nodeSize() const -> Containers::Optional<Vector2>
Size of the node the event is called on.
auto isNodePressed() const -> bool
Whether the event is called on a node that's currently pressed.
auto isNodeHovered() const -> bool
Whether the event is called on a node that's currently hovered.
auto isNodeFocused() const -> bool
Whether the event is called on a node that's currently focused.
auto isCaptured() const -> bool
Whether the event is captured on a node.
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 node-related 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 the top left corner of that node. Use nodeSize() to calculate a position relative to the node size or to other edges / corners.

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

Size of the node the event is called on.

If the event was called on a AbstractUserInterface::currentFocusedNode(), returns Containers::NullOpt, consistently with nodeSize(). Otherwise the node was picked based on pointer position from a preceding pointer press, release or move event, and the function returns a size of given node after all layout calculations.

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

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

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

bool Magnum::Ui::KeyEvent::isNodeHovered() 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::isNodeFocused() 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 isNodeHovered(), 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::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::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.