FifeGUI 0.3.0
A C++ GUI library designed for games.
inputevent.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_INPUTEVENT_HPP_
6#define INCLUDE_FIFECHAN_INPUTEVENT_HPP_
7
8// Standard library includes
9#include <cstdint>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14// Project headers (subdirs before local)
15#include "fifechan/events/event.hpp"
16
17namespace fcn
18{
27 class FIFEGUI_API InputEvent : public Event
28 {
29 public:
32 static constexpr uint16_t ModShift = 1 << 0;
33 static constexpr uint16_t ModControl = 1 << 1;
34 static constexpr uint16_t ModAlt = 1 << 2;
35 static constexpr uint16_t ModMeta = 1 << 3;
36
48 Widget* source,
49 Widget* distributor,
50 bool isShiftPressed,
52 bool isAltPressed,
53 bool isMetaPressed);
54
61 bool isShiftPressed() const;
62
69 bool isControlPressed() const;
70
77 bool isAltPressed() const;
78
85 bool isMetaPressed() const;
86
92 uint16_t getModMask() const;
93
104 void consume();
105
113 bool isConsumed() const;
114
124 Widget* getDistributor() const;
125
126 protected:
130 uint16_t mModMask{0};
131
137
142
152 friend class Gui;
153 };
154} // namespace fcn
155
156#endif // INCLUDE_FIFECHAN_INPUTEVENT_HPP_
Event(Widget *source)
Constructor.
Definition event.cpp:16
Widget * getDistributor() const
Returns the widget that distributed this event.
InputEvent(Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed)
Constructor.
static constexpr uint16_t ModControl
Control key.
friend class Gui
Grants Gui privileged access to internal state.
bool mIsConsumed
True if the input event is consumed, false otherwise.
uint16_t getModMask() const
Gets the modifier bitmask.
bool isConsumed() const
Checks if the input event is consumed.
bool isAltPressed() const
Checks if alt is pressed.
bool isControlPressed() const
Checks if control is pressed.
bool isMetaPressed() const
Checks whether meta is pressed.
void consume()
Marks this event as consumed.
static constexpr uint16_t ModMeta
Meta (GUI/Command) key.
static constexpr uint16_t ModShift
Modifier bitmask flags, matching Shortcut::Modifier positions.
static constexpr uint16_t ModAlt
Alt key.
uint16_t mModMask
Modifier bitmask (ModShift | ModControl | ModAlt | ModMeta).
Widget * mDistributor
Holds the distributor of the event.
bool isShiftPressed() const
Checks if shift is pressed.
Abstract base class defining the common behavior, properties, and lifecycle of all GUI elements.
Definition widget.hpp:56
Used replacement tokens by configure_file():