FifeGUI 0.3.0
A C++ GUI library designed for games.
fcn::InputEvent Class Reference

#include <inputevent.hpp>

Inheritance diagram for fcn::InputEvent:
fcn::Event fcn::KeyEvent fcn::MouseEvent fcn::TextInputEvent

Public Member Functions

void consume ()
WidgetgetDistributor () 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)
WidgetgetSource () 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

WidgetmDistributor
bool mIsConsumed
uint16_t mModMask {0}
Protected Attributes inherited from fcn::Event
WidgetmSource {nullptr}

Friends

class Gui

Detailed Description

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.

Constructor & Destructor Documentation

◆ InputEvent()

fcn::InputEvent::InputEvent ( Widget * source,
Widget * distributor,
bool isShiftPressed,
bool isControlPressed,
bool isAltPressed,
bool isMetaPressed )

Constructor.

Parameters
sourceThe widget the event concerns.
distributorThe distributor of the event.
isShiftPressedTrue if shift is pressed, false otherwise.
isControlPressedTrue if control is pressed, false otherwise.
isAltPressedTrue if alt is pressed, false otherwise.
isMetaPressedTrue 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().

Member Function Documentation

◆ consume()

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.

See also
isConsumed()

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().

◆ getDistributor()

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.

Returns
Pointer to the distributing widget, or nullptr if none.

Definition at line 79 of file inputevent.cpp.

References mDistributor.

◆ getModMask()

uint16_t fcn::InputEvent::getModMask ( ) const

Gets the modifier bitmask.

Returns
The modifier bitmask.

Definition at line 64 of file inputevent.cpp.

References mModMask.

◆ isAltPressed()

bool fcn::InputEvent::isAltPressed ( ) const

Checks if alt is pressed.

Returns
True if alt was pressed at the same time as the key, false otherwise.

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().

◆ isConsumed()

◆ isControlPressed()

bool fcn::InputEvent::isControlPressed ( ) const

Checks if control is pressed.

Returns
True if control was pressed at the same time as the key, false otherwise.

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().

◆ isMetaPressed()

bool fcn::InputEvent::isMetaPressed ( ) const

Checks whether meta is pressed.

Returns
True if meta was pressed at the same time as the key, false otherwise.

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().

◆ isShiftPressed()

bool fcn::InputEvent::isShiftPressed ( ) const

Checks if shift is pressed.

Returns
True if shift was pressed at the same time as the key, false otherwise.

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().

◆ Gui

friend class Gui
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.

Member Data Documentation

◆ mDistributor

Widget* fcn::InputEvent::mDistributor
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().

◆ mIsConsumed

bool fcn::InputEvent::mIsConsumed
protected

True if the input event is consumed, false otherwise.

Definition at line 136 of file inputevent.hpp.

Referenced by consume(), InputEvent(), and isConsumed().

◆ mModMask

uint16_t fcn::InputEvent::mModMask {0}
protected

Modifier bitmask (ModShift | ModControl | ModAlt | ModMeta).

Definition at line 130 of file inputevent.hpp.

Referenced by getModMask(), InputEvent(), isAltPressed(), isControlPressed(), isMetaPressed(), and isShiftPressed().

◆ ModAlt

uint16_t fcn::InputEvent::ModAlt = 1 << 2
staticconstexpr

Alt key.

Definition at line 34 of file inputevent.hpp.

Referenced by InputEvent(), and isAltPressed().

◆ ModControl

uint16_t fcn::InputEvent::ModControl = 1 << 1
staticconstexpr

Control key.

Definition at line 33 of file inputevent.hpp.

Referenced by InputEvent(), and isControlPressed().

◆ ModMeta

uint16_t fcn::InputEvent::ModMeta = 1 << 3
staticconstexpr

Meta (GUI/Command) key.

Definition at line 35 of file inputevent.hpp.

Referenced by InputEvent(), and isMetaPressed().

◆ ModShift

uint16_t fcn::InputEvent::ModShift = 1 << 0
staticconstexpr

Modifier bitmask flags, matching Shortcut::Modifier positions.

See also
getModMask Shift key.

Definition at line 32 of file inputevent.hpp.

Referenced by InputEvent(), and isShiftPressed().


The documentation for this class was generated from the following files: