lxgui
|
Handles inputs (keyboard and mouse) More...
#include <input_dispatcher.hpp>
Public Member Functions | |
dispatcher (source &src) | |
Initializes this dispatcher with a chosen input source. | |
dispatcher (const dispatcher &)=delete | |
dispatcher (dispatcher &&)=delete | |
dispatcher & | operator= (const dispatcher &)=delete |
dispatcher & | operator= (dispatcher &&)=delete |
bool | any_key_is_down () const |
Checks if any key is being pressed. | |
bool | key_is_down (key key_id) const |
Checks if a key is being pressed. | |
double | get_key_down_duration (key key_id) const |
Returns elapsed time since the key has been pressed. | |
bool | alt_is_pressed () const |
Checks if Alt is being pressed. | |
bool | shift_is_pressed () const |
Checks if Shift is being pressed. | |
bool | ctrl_is_pressed () const |
Checks if Control (Ctrl) is being pressed. | |
bool | mouse_is_down (mouse_button button_id) const |
Checks if a mouse button is being pressed. | |
double | get_mouse_down_duration (mouse_button key_id) const |
Returns elapsed time since the mouse button has been pressed. | |
gui::vector2f | get_mouse_position () const |
Returns the position of the mouse in pixels. | |
float | get_mouse_wheel () const |
Returns the accumulated rolling amount of the mouse wheel. | |
void | set_doubleclick_time (double double_click_time) |
Sets the double click maximum time. | |
double | get_doubleclick_time () const |
Returns the double click maximum time. | |
void | set_interface_scaling_factor (float scaling_factor) |
Sets the scaling factor applied to the interface. | |
float | get_interface_scaling_factor () const |
Return the current interface scaling factor. | |
const source & | get_source () const |
Returns the input source. | |
source & | get_source () |
Returns the input source. | |
Public Attributes | |
utils::signal< void(const mouse_moved_data &)> | on_mouse_moved |
Signal triggered when the mouse moves. | |
utils::signal< void(const mouse_wheel_data &)> | on_mouse_wheel |
Signal triggered when the mouse wheel is moved. | |
utils::signal< void(const mouse_pressed_data &)> | on_mouse_pressed |
Signal triggered when a mouse button is pressed. | |
utils::signal< void(const mouse_released_data &)> | on_mouse_released |
Signal triggered when a mouse button is released. | |
utils::signal< void(const mouse_double_clicked_data &)> | on_mouse_double_clicked |
Signal triggered when a mouse button is double clicked. | |
utils::signal< void(const mouse_drag_start_data &)> | on_mouse_drag_start |
Signal triggered when the mouse starts a drag operation. | |
utils::signal< void(const mouse_drag_stop_data &)> | on_mouse_drag_stop |
Signal triggered when the mouse ends a drag operation. | |
utils::signal< void(const key_pressed_data &)> | on_key_pressed |
Signal triggered when a keyboard key is pressed. | |
utils::signal< void(const key_pressed_repeat_data &)> | on_key_pressed_repeat |
Signal triggered when a keyboard key is long-pressed and repeats. | |
utils::signal< void(const key_released_data &)> | on_key_released |
Signal triggered when a keyboard key is released. | |
utils::signal< void(const text_entered_data &)> | on_text_entered |
Signal triggered when text is entered. | |
Handles inputs (keyboard and mouse)
The implementation is responsible for generating the following events:
These events are "global" and are not restricted by the UI. For example, on_mouse_pressed will trigger whenever a mouse button is pressed, even if the mouse pointer is currently over a UI element that should capture mouse input. Likewise, on_key_pressed will trigger even if a UI element has focus. These global events are meant to be consumed by the gui::root, which takes care of forwarding them to UI elements, and determining if a particular event is allowed to propagate to the elements below the UI. If you need to react only to events that are not captured by the UI, use events from input::world_dispatcher instead.
Definition at line 46 of file input_dispatcher.hpp.
|
explicit |
Initializes this dispatcher with a chosen input source.
src | The input source |
Definition at line 15 of file input_dispatcher.cpp.
|
delete |
|
delete |
bool lxgui::input::dispatcher::alt_is_pressed | ( | ) | const |
Checks if Alt is being pressed.
Definition at line 149 of file input_dispatcher.cpp.
bool lxgui::input::dispatcher::any_key_is_down | ( | ) | const |
Checks if any key is being pressed.
Definition at line 105 of file input_dispatcher.cpp.
bool lxgui::input::dispatcher::ctrl_is_pressed | ( | ) | const |
Checks if Control (Ctrl) is being pressed.
Definition at line 157 of file input_dispatcher.cpp.
double lxgui::input::dispatcher::get_doubleclick_time | ( | ) | const |
Returns the double click maximum time.
Definition at line 145 of file input_dispatcher.cpp.
float lxgui::input::dispatcher::get_interface_scaling_factor | ( | ) | const |
Return the current interface scaling factor.
Definition at line 181 of file input_dispatcher.cpp.
double lxgui::input::dispatcher::get_key_down_duration | ( | key | key_id | ) | const |
Returns elapsed time since the key has been pressed.
key_id | The ID code of the key you are interested in |
Definition at line 119 of file input_dispatcher.cpp.
double lxgui::input::dispatcher::get_mouse_down_duration | ( | mouse_button | key_id | ) | const |
Returns elapsed time since the mouse button has been pressed.
key_id | The ID code of the mouse button you are interested in |
Definition at line 132 of file input_dispatcher.cpp.
gui::vector2f lxgui::input::dispatcher::get_mouse_position | ( | ) | const |
Returns the position of the mouse in pixels.
Definition at line 161 of file input_dispatcher.cpp.
float lxgui::input::dispatcher::get_mouse_wheel | ( | ) | const |
Returns the accumulated rolling amount of the mouse wheel.
Definition at line 165 of file input_dispatcher.cpp.
source & lxgui::input::dispatcher::get_source | ( | ) |
Returns the input source.
Definition at line 173 of file input_dispatcher.cpp.
const source & lxgui::input::dispatcher::get_source | ( | ) | const |
Returns the input source.
Definition at line 169 of file input_dispatcher.cpp.
bool lxgui::input::dispatcher::key_is_down | ( | key | key_id | ) | const |
Checks if a key is being pressed.
key_id | The ID code of the key you are interested in |
Definition at line 115 of file input_dispatcher.cpp.
bool lxgui::input::dispatcher::mouse_is_down | ( | mouse_button | button_id | ) | const |
Checks if a mouse button is being pressed.
button_id | The ID code of the mouse button you are interested in |
Definition at line 128 of file input_dispatcher.cpp.
|
delete |
|
delete |
void lxgui::input::dispatcher::set_doubleclick_time | ( | double | double_click_time | ) |
Sets the double click maximum time.
double_click_time | Maximum amount of time between two clicks in a double click |
Definition at line 141 of file input_dispatcher.cpp.
void lxgui::input::dispatcher::set_interface_scaling_factor | ( | float | scaling_factor | ) |
Sets the scaling factor applied to the interface.
scaling_factor | The new scaling factor (default: 1) |
Definition at line 177 of file input_dispatcher.cpp.
bool lxgui::input::dispatcher::shift_is_pressed | ( | ) | const |
Checks if Shift is being pressed.
Definition at line 153 of file input_dispatcher.cpp.
|
inherited |
Signal triggered when a keyboard key is pressed.
Definition at line 125 of file input_signals.hpp.
|
inherited |
Signal triggered when a keyboard key is long-pressed and repeats.
Definition at line 130 of file input_signals.hpp.
|
inherited |
Signal triggered when a keyboard key is released.
Definition at line 135 of file input_signals.hpp.
|
inherited |
Signal triggered when a mouse button is double clicked.
Definition at line 110 of file input_signals.hpp.
|
inherited |
Signal triggered when the mouse starts a drag operation.
Definition at line 115 of file input_signals.hpp.
|
inherited |
Signal triggered when the mouse ends a drag operation.
Definition at line 120 of file input_signals.hpp.
|
inherited |
Signal triggered when the mouse moves.
Definition at line 90 of file input_signals.hpp.
|
inherited |
Signal triggered when a mouse button is pressed.
Definition at line 100 of file input_signals.hpp.
|
inherited |
Signal triggered when a mouse button is released.
Definition at line 105 of file input_signals.hpp.
|
inherited |
Signal triggered when the mouse wheel is moved.
Definition at line 95 of file input_signals.hpp.
|
inherited |
Signal triggered when text is entered.
Definition at line 141 of file input_signals.hpp.