FifeGUI
0.3.0
A C++ GUI library designed for games.
src
events
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
17
namespace
fcn
18
{
19
InputEvent::InputEvent
(
20
Widget
* source,
21
Widget
* distributor,
22
bool
isShiftPressed
,
23
bool
isControlPressed
,
24
bool
isAltPressed
,
25
bool
isMetaPressed
) :
26
Event
(source),
mIsConsumed
(false),
mDistributor
(distributor)
27
{
28
(void)source;
29
(void)distributor;
30
if
(
isShiftPressed
) {
31
mModMask
|=
ModShift
;
32
}
33
if
(
isControlPressed
) {
34
mModMask
|=
ModControl
;
35
}
36
if
(
isAltPressed
) {
37
mModMask
|=
ModAlt
;
38
}
39
if
(
isMetaPressed
) {
40
mModMask
|=
ModMeta
;
41
}
42
}
43
44
bool
InputEvent::isShiftPressed
()
const
45
{
46
return
(
mModMask
&
ModShift
) != 0;
47
}
48
49
bool
InputEvent::isControlPressed
()
const
50
{
51
return
(
mModMask
&
ModControl
) != 0;
52
}
53
54
bool
InputEvent::isAltPressed
()
const
55
{
56
return
(
mModMask
&
ModAlt
) != 0;
57
}
58
59
bool
InputEvent::isMetaPressed
()
const
60
{
61
return
(
mModMask
&
ModMeta
) != 0;
62
}
63
64
uint16_t
InputEvent::getModMask
()
const
65
{
66
return
mModMask
;
67
}
68
69
void
InputEvent::consume
()
70
{
71
mIsConsumed
=
true
;
72
}
73
74
bool
InputEvent::isConsumed
()
const
75
{
76
return
mIsConsumed
;
77
}
78
79
Widget
*
InputEvent::getDistributor
()
const
80
{
81
return
mDistributor
;
82
}
83
}
// namespace fcn
fcn::Event::Event
Event(Widget *source)
Constructor.
Definition
event.cpp:16
fcn::InputEvent::getDistributor
Widget * getDistributor() const
Returns the widget that distributed this event.
Definition
inputevent.cpp:79
fcn::InputEvent::InputEvent
InputEvent(Widget *source, Widget *distributor, bool isShiftPressed, bool isControlPressed, bool isAltPressed, bool isMetaPressed)
Constructor.
Definition
inputevent.cpp:19
fcn::InputEvent::ModControl
static constexpr uint16_t ModControl
Control key.
Definition
inputevent.hpp:33
fcn::InputEvent::mIsConsumed
bool mIsConsumed
True if the input event is consumed, false otherwise.
Definition
inputevent.hpp:136
fcn::InputEvent::getModMask
uint16_t getModMask() const
Gets the modifier bitmask.
Definition
inputevent.cpp:64
fcn::InputEvent::isConsumed
bool isConsumed() const
Checks if the input event is consumed.
Definition
inputevent.cpp:74
fcn::InputEvent::isAltPressed
bool isAltPressed() const
Checks if alt is pressed.
Definition
inputevent.cpp:54
fcn::InputEvent::isControlPressed
bool isControlPressed() const
Checks if control is pressed.
Definition
inputevent.cpp:49
fcn::InputEvent::isMetaPressed
bool isMetaPressed() const
Checks whether meta is pressed.
Definition
inputevent.cpp:59
fcn::InputEvent::consume
void consume()
Marks this event as consumed.
Definition
inputevent.cpp:69
fcn::InputEvent::ModMeta
static constexpr uint16_t ModMeta
Meta (GUI/Command) key.
Definition
inputevent.hpp:35
fcn::InputEvent::ModShift
static constexpr uint16_t ModShift
Modifier bitmask flags, matching Shortcut::Modifier positions.
Definition
inputevent.hpp:32
fcn::InputEvent::ModAlt
static constexpr uint16_t ModAlt
Alt key.
Definition
inputevent.hpp:34
fcn::InputEvent::mModMask
uint16_t mModMask
Modifier bitmask (ModShift | ModControl | ModAlt | ModMeta).
Definition
inputevent.hpp:130
fcn::InputEvent::mDistributor
Widget * mDistributor
Holds the distributor of the event.
Definition
inputevent.hpp:141
fcn::InputEvent::isShiftPressed
bool isShiftPressed() const
Checks if shift is pressed.
Definition
inputevent.cpp:44
fcn::Widget
Abstract base class defining the common behavior, properties, and lifecycle of all GUI elements.
Definition
widget.hpp:56
fcn
Used replacement tokens by configure_file():
Definition
backends/opengl/graphics.hpp:17
Generated by
1.17.0