|
FifeGUI 0.3.0
A C++ GUI library designed for games.
|
#include <inputevent.hpp>
Public Member Functions | |
| void | consume () |
| Widget * | getDistributor () const |
| uint16_t | getModMask () const |
| InputEvent (Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed) | |
| bool | isAltPressed () const |
| bool | isConsumed () const |
| bool | isControlPressed () const |
| bool | isMetaPressed () const |
| bool | isShiftPressed () const |
| Public Member Functions inherited from fcn::Event | |
| Event (Widget *source) | |
| Widget * | getSource () const |
Static Public Attributes | |
| static constexpr uint16_t | ModAlt = 1 << 2 |
| static constexpr uint16_t | ModControl = 1 << 1 |
| static constexpr uint16_t | ModMeta = 1 << 3 |
| static constexpr uint16_t | ModShift = 1 << 0 |
Protected Attributes | |
| Widget * | mDistributor |
| bool | mIsConsumed |
| uint16_t | mModMask {0} |
| Protected Attributes inherited from fcn::Event | |
| Widget * | mSource {nullptr} |
Friends | |
| class | Gui |
Base class for all input-related events (keyboard, mouse).
Modifier state is stored as a bitmask. The public query methods (isShiftPressed(), etc.) are retained for backward compatibility.
Definition at line 27 of file inputevent.hpp.
| fcn::InputEvent::InputEvent | ( | Widget * | source, |
| Widget * | distributor, | ||
| bool | isShiftPressed, | ||
| bool | isControlPressed, | ||
| bool | isAltPressed, | ||
| bool | isMetaPressed ) |
Constructor.
| source | The widget the event concerns. |
| distributor | The distributor of the event. |
| isShiftPressed | True if shift is pressed, false otherwise. |
| isControlPressed | True if control is pressed, false otherwise. |
| isAltPressed | True if alt is pressed, false otherwise. |
| isMetaPressed | True if meta is pressed, false otherwise. |
Definition at line 19 of file inputevent.cpp.
References fcn::Event::Event(), isAltPressed(), isControlPressed(), isMetaPressed(), isShiftPressed(), mDistributor, mIsConsumed, mModMask, ModAlt, ModControl, ModMeta, and ModShift.
Referenced by fcn::KeyEvent::KeyEvent(), fcn::MouseEvent::MouseEvent(), and fcn::TextInputEvent::TextInputEvent().
| void fcn::InputEvent::consume | ( | ) |
Marks this event as consumed.
Consumed events may be ignored by some listeners or handled differently. For example, a ScrollArea may discard consumed mouse wheel events to prevent scrolling when a child widget (e.g., a slider) has already handled the input.
Definition at line 69 of file inputevent.cpp.
References mIsConsumed.
Referenced by fcn::Button::keyPressed(), fcn::CheckBox::keyPressed(), fcn::DropDown::keyPressed(), fcn::ListBox::keyPressed(), fcn::PasswordField::keyPressed(), fcn::Slider::keyPressed(), fcn::TabbedArea::keyPressed(), fcn::TextBox::keyPressed(), fcn::TextField::keyPressed(), fcn::Button::keyReleased(), fcn::CheckBox::keyReleased(), fcn::ToggleButton::keyReleased(), fcn::CheckBox::mouseClicked(), fcn::Button::mouseDragged(), fcn::DropDown::mouseDragged(), fcn::ListBox::mouseDragged(), fcn::ScrollArea::mouseDragged(), fcn::Slider::mouseDragged(), fcn::TextBox::mouseDragged(), fcn::TextField::mouseDragged(), fcn::Window::mouseDragged(), fcn::Button::mousePressed(), fcn::CheckBox::mousePressed(), fcn::TextBox::mousePressed(), fcn::Button::mouseReleased(), fcn::CheckBox::mouseReleased(), fcn::ScrollArea::mouseReleased(), fcn::ToggleButton::mouseReleased(), fcn::DropDown::mouseWheelMovedDown(), fcn::ListBox::mouseWheelMovedDown(), fcn::ScrollArea::mouseWheelMovedDown(), fcn::Slider::mouseWheelMovedDown(), fcn::ScrollArea::mouseWheelMovedLeft(), fcn::Slider::mouseWheelMovedLeft(), fcn::ScrollArea::mouseWheelMovedRight(), fcn::Slider::mouseWheelMovedRight(), fcn::DropDown::mouseWheelMovedUp(), fcn::ListBox::mouseWheelMovedUp(), fcn::ScrollArea::mouseWheelMovedUp(), and fcn::Slider::mouseWheelMovedUp().
| Widget * fcn::InputEvent::getDistributor | ( | ) | const |
Returns the widget that distributed this event.
The distributor indicates which widget originally propagated the event. This may differ from the event source due to event bubbling through the widget hierarchy.
Definition at line 79 of file inputevent.cpp.
References mDistributor.
| uint16_t fcn::InputEvent::getModMask | ( | ) | const |
Gets the modifier bitmask.
Definition at line 64 of file inputevent.cpp.
References mModMask.
| bool fcn::InputEvent::isAltPressed | ( | ) | const |
Checks if alt is pressed.
Definition at line 54 of file inputevent.cpp.
References mModMask, and ModAlt.
Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), fcn::Shortcut::matches(), fcn::MouseEvent::MouseEvent(), and fcn::TextInputEvent::TextInputEvent().
| bool fcn::InputEvent::isConsumed | ( | ) | const |
Checks if the input event is consumed.
Definition at line 74 of file inputevent.cpp.
References mIsConsumed.
Referenced by fcn::Gui::distributeKeyEventToGlobalKeyListeners(), fcn::Gui::handleKeyInput(), fcn::DropDown::keyPressed(), fcn::TabbedArea::keyPressed(), fcn::CheckBox::mouseClicked(), fcn::Window::mouseDragged(), fcn::ScrollArea::mouseWheelMovedDown(), fcn::ScrollArea::mouseWheelMovedLeft(), fcn::ScrollArea::mouseWheelMovedRight(), and fcn::ScrollArea::mouseWheelMovedUp().
| bool fcn::InputEvent::isControlPressed | ( | ) | const |
Checks if control is pressed.
Definition at line 49 of file inputevent.cpp.
References mModMask, and ModControl.
Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), fcn::Shortcut::matches(), fcn::MouseEvent::MouseEvent(), and fcn::TextInputEvent::TextInputEvent().
| bool fcn::InputEvent::isMetaPressed | ( | ) | const |
Checks whether meta is pressed.
Definition at line 59 of file inputevent.cpp.
References mModMask, and ModMeta.
Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), fcn::Shortcut::matches(), fcn::MouseEvent::MouseEvent(), and fcn::TextInputEvent::TextInputEvent().
| bool fcn::InputEvent::isShiftPressed | ( | ) | const |
Checks if shift is pressed.
Definition at line 44 of file inputevent.cpp.
References mModMask, and ModShift.
Referenced by InputEvent(), fcn::KeyEvent::KeyEvent(), fcn::Shortcut::matches(), fcn::MouseEvent::MouseEvent(), and fcn::TextInputEvent::TextInputEvent().
|
friend |
Grants Gui privileged access to internal state.
Gui is declared as a friend in order to be able to manipulate the protected member variables of this class and at the same time keep the MouseEvent class as const as possible. Gui needs to update the distributer of this class whenever the distributer changes as events bubble up.
Definition at line 152 of file inputevent.hpp.
References Gui.
Referenced by Gui.
|
protected |
Holds the distributor of the event.
Definition at line 141 of file inputevent.hpp.
Referenced by fcn::Gui::distributeKeyEvent(), fcn::Gui::distributeMouseEvent(), getDistributor(), and InputEvent().
|
protected |
True if the input event is consumed, false otherwise.
Definition at line 136 of file inputevent.hpp.
Referenced by consume(), InputEvent(), and isConsumed().
|
protected |
Modifier bitmask (ModShift | ModControl | ModAlt | ModMeta).
Definition at line 130 of file inputevent.hpp.
Referenced by getModMask(), InputEvent(), isAltPressed(), isControlPressed(), isMetaPressed(), and isShiftPressed().
|
staticconstexpr |
Alt key.
Definition at line 34 of file inputevent.hpp.
Referenced by InputEvent(), and isAltPressed().
|
staticconstexpr |
Control key.
Definition at line 33 of file inputevent.hpp.
Referenced by InputEvent(), and isControlPressed().
|
staticconstexpr |
Meta (GUI/Command) key.
Definition at line 35 of file inputevent.hpp.
Referenced by InputEvent(), and isMetaPressed().
|
staticconstexpr |
Modifier bitmask flags, matching Shortcut::Modifier positions.
Definition at line 32 of file inputevent.hpp.
Referenced by InputEvent(), and isShiftPressed().