CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
UIResponder.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "UIEvent.hpp"
11
13
14namespace CeresEngine {
15
34 public:
35 virtual ~UIResponder() = default;
36
37 public:
45 [[nodiscard]] virtual bool acceptsFirstResponder() const { return false; }
46
58 [[nodiscard]] virtual bool becomeFirstResponder() { return true; }
59
71 [[nodiscard]] virtual bool resignFirstResponder() { return true; }
72
77 [[nodiscard]] virtual UIResponder* getNextResponder() const { return nullptr; }
78
79 public: // Mouse Events
81 virtual void mouseDown(const UIMouseEvent& event);
82
85 virtual void mouseDragged(const UIMouseEvent& event);
86
88 virtual void mouseUp(const UIMouseEvent& event);
89
91 virtual void mouseMoved(const UIMouseEvent& event);
92
94 virtual void mouseEntered(const UIMouseEvent& event);
95
97 virtual void mouseExited(const UIMouseEvent& event);
98
100 virtual void rightMouseDown(const UIMouseEvent& event);
101
104 virtual void rightMouseDragged(const UIMouseEvent& event);
105
107 virtual void rightMouseUp(const UIMouseEvent& event);
108
111 virtual void otherMouseDown(const UIMouseEvent& event);
112
115 virtual void otherMouseDragged(const UIMouseEvent& event);
116
119 virtual void otherMouseUp(const UIMouseEvent& event);
120
122 virtual void scrollWheel(const UIMouseEvent& event);
123
124 public: // Key Events
126 virtual void keyDown(const UIKeyEvent& event);
127
129 virtual void keyUp(const UIKeyEvent& event);
130
132 virtual void interpretKeyEvents(const Vector<UIKeyEvent>& events);
133
135 virtual bool performKeyEquivalent(const UIKeyEvent& event);
136
139
140 public:
143 virtual void cursorUpdate(const UIEvent& event);
144
149 virtual void flagsChanged(const UIEvent& event);
150
151 public:
156 static void dispatch(UIResponder* const firstResponder, const UIEvent& event);
157 };
158
159} // namespace CeresEngine
An abstract class that forms the basis of event and command processing in the UI framework.
Definition UIResponder.hpp:33
virtual void mouseEntered(const UIMouseEvent &event)
Informs the receiver that the cursor has entered a tracking rectangle.
static void dispatch(UIResponder *const firstResponder, const UIEvent &event)
Dispatches a UIEvent to the given first responder.
virtual UIResponder * getNextResponder() const
The next responder after this one, or nil if it has none.
Definition UIResponder.hpp:77
virtual void mouseExited(const UIMouseEvent &event)
Informs the receiver that the cursor has exited a tracking rectangle.
virtual bool resignFirstResponder()
Notifies the receiver that it's been asked to relinquish its status as first responder in its window.
Definition UIResponder.hpp:71
virtual bool becomeFirstResponder()
Notifies the receiver that it's about to become first responder in its window.
Definition UIResponder.hpp:58
virtual void cursorUpdate(const UIEvent &event)
Informs the receiver that the mouse cursor has moved into a cursor rectangle.
virtual void interpretKeyEvents(const Vector< UIKeyEvent > &events)
Handles a series of key events.
virtual ~UIResponder()=default
virtual void mouseDragged(const UIMouseEvent &event)
Informs the receiver that the user has moved the mouse with the left button pressed.
virtual void rightMouseUp(const UIMouseEvent &event)
Informs the receiver that the user has released the right mouse button.
virtual void rightMouseDragged(const UIMouseEvent &event)
Informs the receiver that the user has moved the mouse with the right button pressed.
virtual void flushBufferedKeyEvents()
Clears any unprocessed key events when overridden by subclasses.
virtual void mouseMoved(const UIMouseEvent &event)
Informs the receiver that the mouse has moved.
virtual void mouseUp(const UIMouseEvent &event)
Informs the receiver that the user has released the left mouse button.
virtual void flagsChanged(const UIEvent &event)
Informs the receiver that the user has pressed or released a modifier key (Shift, Control,...
virtual void rightMouseDown(const UIMouseEvent &event)
Informs the receiver that the user has pressed the right mouse button.
virtual bool acceptsFirstResponder() const
A Boolean value that indicates whether the responder accepts first responder status.
Definition UIResponder.hpp:45
virtual bool performKeyEquivalent(const UIKeyEvent &event)
Handle a key equivalent.
virtual void otherMouseDown(const UIMouseEvent &event)
Informs the receiver that the user has pressed a mouse button other than the left or right one.
virtual void keyDown(const UIKeyEvent &event)
Informs the receiver that the user has pressed a key.
virtual void otherMouseUp(const UIMouseEvent &event)
Informs the receiver that the user has released a mouse button other than the left or right button.
virtual void keyUp(const UIKeyEvent &event)
Informs the receiver that the user has released a key.
virtual void otherMouseDragged(const UIMouseEvent &event)
Informs the receiver that the user has moved the mouse with a button other than the left or right but...
virtual void mouseDown(const UIMouseEvent &event)
Informs the receiver that the user has pressed the left mouse button.
virtual void scrollWheel(const UIMouseEvent &event)
Informs the receiver that the mouse's scroll wheel has moved.
Definition Application.hpp:19
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
An object that contains information about an input action such as a mouse click or a key press.
Definition UIEvent.hpp:115
Definition UIEvent.hpp:129
Definition UIEvent.hpp:173