FifeGUI 0.3.0
A C++ GUI library designed for games.
inputevent.cpp
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// Corresponding header include
6#include "fifechan/events/inputevent.hpp"
7
8// Standard library includes
9#include <cassert>
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{
20 Widget* source,
21 Widget* distributor,
22 bool isShiftPressed,
24 bool isAltPressed,
25 bool isMetaPressed) :
26 Event(source), mIsConsumed(false), mDistributor(distributor)
27 {
28 (void)source;
29 (void)distributor;
30 if (isShiftPressed) {
32 }
33 if (isControlPressed) {
35 }
36 if (isAltPressed) {
38 }
39 if (isMetaPressed) {
41 }
42 }
43
45 {
46 return (mModMask & ModShift) != 0;
47 }
48
50 {
51 return (mModMask & ModControl) != 0;
52 }
53
55 {
56 return (mModMask & ModAlt) != 0;
57 }
58
60 {
61 return (mModMask & ModMeta) != 0;
62 }
63
64 uint16_t InputEvent::getModMask() const
65 {
66 return mModMask;
67 }
68
70 {
71 mIsConsumed = true;
72 }
73
75 {
76 return mIsConsumed;
77 }
78
80 {
81 return mDistributor;
82 }
83} // namespace fcn
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.
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():