AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
MouseEvent.hpp
1/*
2Copyright (C) 2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_DOM_MOUSEEVENT_H
17#define AEONGUI_DOM_MOUSEEVENT_H
18#include "aeongui/dom/UIEvent.hpp"
19#include "aeongui/dom/EventModifierInit.hpp"
20
21namespace AeonGUI
22{
23 namespace DOM
24 {
25 class EventTarget;
26
31 {
32 double screenX{0.0};
33 double screenY{0.0};
34 double clientX{0.0};
35 double clientY{0.0};
36 short button{0};
37 unsigned short buttons{0};
39 };
40
47 class MouseEvent : public UIEvent
48 {
49 public:
54 DLL MouseEvent ( const DOMString& type, const MouseEventInit& eventInitDict = {} );
55
58 DLL double screenX() const;
61 DLL double screenY() const;
64 DLL double clientX() const;
67 DLL double clientY() const;
70 DLL bool ctrlKey() const;
73 DLL bool shiftKey() const;
76 DLL bool altKey() const;
79 DLL bool metaKey() const;
82 DLL short button() const;
85 DLL unsigned short buttons() const;
88 DLL EventTarget* relatedTarget() const;
92 DLL bool getModifierState ( const DOMString& keyArg ) const;
93
94 protected:
95 double m_screenX{0.0};
96 double m_screenY{0.0};
97 double m_clientX{0.0};
98 double m_clientY{0.0};
99 bool m_ctrlKey{false};
100 bool m_shiftKey{false};
101 bool m_altKey{false};
102 bool m_metaKey{false};
103 short m_button{0};
104 unsigned short m_buttons{0};
106 bool m_modifierAltGraph{false};
107 bool m_modifierCapsLock{false};
108 bool m_modifierFn{false};
109 bool m_modifierFnLock{false};
110 bool m_modifierHyper{false};
111 bool m_modifierNumLock{false};
113 bool m_modifierSuper{false};
114 bool m_modifierSymbol{false};
116 };
117 }
118}
119#endif
constexpr const DOMString & type() const
Get the event type.
Definition Event.hpp:73
Base class for objects that can receive DOM events.
Definition EventTarget.hpp:58
bool shiftKey() const
Check if Shift modifier was active.
Definition MouseEvent.cpp:68
double clientY() const
Vertical coordinate relative to viewport, as a double.
Definition MouseEvent.cpp:60
bool m_modifierScrollLock
State of ScrollLock modifier.
Definition MouseEvent.hpp:112
double screenX() const
Horizontal coordinate relative to screen origin, as a double.
Definition MouseEvent.cpp:48
bool m_modifierNumLock
State of NumLock modifier.
Definition MouseEvent.hpp:111
unsigned short m_buttons
Bitmask of currently pressed buttons.
Definition MouseEvent.hpp:104
bool m_modifierSymbol
State of Symbol modifier.
Definition MouseEvent.hpp:114
short m_button
Button that changed state.
Definition MouseEvent.hpp:103
double m_clientY
Vertical coordinate in viewport space.
Definition MouseEvent.hpp:98
bool getModifierState(const DOMString &keyArg) const
Query the state of a modifier key.
Definition MouseEvent.cpp:93
double m_screenX
Horizontal coordinate in screen space.
Definition MouseEvent.hpp:95
bool m_modifierSuper
State of Super modifier.
Definition MouseEvent.hpp:113
bool altKey() const
Check if Alt modifier was active.
Definition MouseEvent.cpp:72
bool ctrlKey() const
Check if Control modifier was active.
Definition MouseEvent.cpp:64
bool m_ctrlKey
State of Control modifier.
Definition MouseEvent.hpp:99
EventTarget * m_relatedTarget
Related target for enter/leave style events.
Definition MouseEvent.hpp:105
EventTarget * relatedTarget() const
Get the related target.
Definition MouseEvent.cpp:88
bool m_modifierFnLock
State of FnLock modifier.
Definition MouseEvent.hpp:109
MouseEvent(const DOMString &type, const MouseEventInit &eventInitDict={})
Construct a MouseEvent.
Definition MouseEvent.cpp:22
bool metaKey() const
Check if Meta modifier was active.
Definition MouseEvent.cpp:76
bool m_modifierHyper
State of Hyper modifier.
Definition MouseEvent.hpp:110
bool m_modifierSymbolLock
State of SymbolLock modifier.
Definition MouseEvent.hpp:115
bool m_modifierCapsLock
State of CapsLock modifier.
Definition MouseEvent.hpp:107
bool m_modifierFn
State of Fn modifier.
Definition MouseEvent.hpp:108
double screenY() const
Vertical coordinate relative to screen origin, as a double.
Definition MouseEvent.cpp:52
bool m_metaKey
State of Meta modifier.
Definition MouseEvent.hpp:102
bool m_modifierAltGraph
State of AltGraph modifier.
Definition MouseEvent.hpp:106
bool m_altKey
State of Alt modifier.
Definition MouseEvent.hpp:101
double m_screenY
Vertical coordinate in screen space.
Definition MouseEvent.hpp:96
double clientX() const
Horizontal coordinate relative to viewport, as a double.
Definition MouseEvent.cpp:56
short button() const
Get the button number that changed state.
Definition MouseEvent.cpp:80
double m_clientX
Horizontal coordinate in viewport space.
Definition MouseEvent.hpp:97
bool m_shiftKey
State of Shift modifier.
Definition MouseEvent.hpp:100
unsigned short buttons() const
Get the bitmask of currently pressed buttons.
Definition MouseEvent.cpp:84
UIEvent(const DOMString &type, const UIEventInit &eventInitDict={})
Construct a UIEvent.
Definition UIEvent.cpp:21
Shared modifier key initialization dictionary.
Definition EventModifierInit.hpp:31
Initialization dictionary for MouseEvent construction.
Definition MouseEvent.hpp:31
double screenX
Horizontal coordinate relative to screen origin.
Definition MouseEvent.hpp:32
short button
Button number that changed state.
Definition MouseEvent.hpp:36
unsigned short buttons
Bitmask of currently pressed buttons.
Definition MouseEvent.hpp:37
double clientY
Vertical coordinate relative to viewport.
Definition MouseEvent.hpp:35
EventTarget * relatedTarget
Related target for enter/leave events.
Definition MouseEvent.hpp:38
double screenY
Vertical coordinate relative to screen origin.
Definition MouseEvent.hpp:33
double clientX
Horizontal coordinate relative to viewport.
Definition MouseEvent.hpp:34