|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Which buttons of an input device are held on an entity, and what to call when one is pressed or released on it. More...
#include <headers/guillaume/components/button_interaction.hpp>


Public Types | |
| using | ButtonPressHandler = std::function<void(void)> |
| Callback run when a button is pressed on the entity. | |
| using | ButtonReleaseHandler = std::function<void(void)> |
| Callback run when a button pressed on the entity is released on it. | |
Public Member Functions | |
| ButtonInteraction (void) | |
| Construct the component with every button of ButtonsArray released and without handler. | |
| ~ButtonInteraction (void)=default | |
| Default destructor. | |
| ButtonInteraction & | setOnButtonPressHandler (const ButtonEnum &button, const ButtonPressHandler &handler) |
| Store the callback run when a button is pressed on the entity. | |
| const ButtonPressHandler & | getOnButtonPressHandler (const ButtonEnum &button) const |
| Get the callback run when a button is pressed on the entity. | |
| ButtonInteraction & | setOnButtonReleaseHandler (const ButtonEnum &button, const ButtonReleaseHandler &handler) |
| Store the callback run when a button pressed on the entity is released on it. | |
| const ButtonReleaseHandler & | getOnButtonReleaseHandler (const ButtonEnum &button) const |
| Get the callback run when a button pressed on the entity is released on it. | |
| bool | isButtonPressed (const ButtonEnum &button) const |
| Check whether a button is held on the entity. | |
| ButtonInteraction & | setButtonPressed (const ButtonEnum &button, bool pressed) |
| Record whether a button is held on the entity. | |
| Public Member Functions inherited from guillaume::ecs::Component | |
| bool | hasChanged (void) const |
| Tell whether a value of the component changed since the flags were last reset (the end of the previous frame). | |
| void | setHasChanged (bool hasChanged) |
| Raise or lower the changed flag. | |
| Component (void)=default | |
| Create a component that is not marked as changed. | |
| virtual | ~Component (void)=default |
| Virtual destructor, so components can be destroyed through the base class. | |
Which buttons of an input device are held on an entity, and what to call when one is pressed or released on it.
It is used through its two aliases, MouseButtonInteraction and HandButtonInteraction. The system of the device (systems::MouseButton, systems::HandButton) writes it in the Event phase, when a button event arrives:
systems::StyleState, systems::Focus and systems::Drag read the pressed state of the primary button (left mouse button, hand button A).
Widgets wire the primary button with systems::interaction::makeInteractive, which replaces the press and release handlers of that button.
| EventType | The button event of the device. It only makes the mouse and hand components distinct types. |
| ButtonEnum | The enumeration naming the buttons of the device. |
| N | Number of buttons in ButtonsArray. |
| ButtonsArray | The buttons the component tracks. Each one starts released and without handler. |
Definition at line 83 of file button_interaction.hpp.
| using guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::ButtonPressHandler = std::function<void(void)> |
Callback run when a button is pressed on the entity.
Definition at line 89 of file button_interaction.hpp.
| using guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::ButtonReleaseHandler = std::function<void(void)> |
Callback run when a button pressed on the entity is released on it.
Definition at line 94 of file button_interaction.hpp.
| const ButtonPressHandler & guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::getOnButtonPressHandler | ( | const ButtonEnum & | button | ) | const |
Get the callback run when a button is pressed on the entity.
| button | The button to look up. |
| std::invalid_argument | If button is neither in ButtonsArray nor a button a handler was set for. |
| const ButtonReleaseHandler & guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::getOnButtonReleaseHandler | ( | const ButtonEnum & | button | ) | const |
Get the callback run when a button pressed on the entity is released on it.
| button | The button to look up. |
| std::invalid_argument | If button is neither in ButtonsArray nor a button a handler was set for. |
| bool guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::isButtonPressed | ( | const ButtonEnum & | button | ) | const |
Check whether a button is held on the entity.
| button | The button to check. |
| ButtonInteraction & guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::setButtonPressed | ( | const ButtonEnum & | button, |
| bool | pressed ) |
Record whether a button is held on the entity.
Called by the input system of the device; it calls no handler. Marks the component changed only when the state differs.
| button | The button to update. |
| pressed | True when the button is held on the entity. |
| ButtonInteraction & guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::setOnButtonPressHandler | ( | const ButtonEnum & | button, |
| const ButtonPressHandler & | handler ) |
Store the callback run when a button is pressed on the entity.
Always marks the component changed.
| button | The button the handler is for. |
| handler | The callback, or nullptr to remove the current one. |
| ButtonInteraction & guillaume::components::ButtonInteraction< EventType, ButtonEnum, N, ButtonsArray >::setOnButtonReleaseHandler | ( | const ButtonEnum & | button, |
| const ButtonReleaseHandler & | handler ) |
Store the callback run when a button pressed on the entity is released on it.
Always marks the component changed.
| button | The button the handler is for. |
| handler | The callback, or nullptr to remove the current one. |