summaryrefslogtreecommitdiff
path: root/core/input
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-08-10 18:55:22 +0200
committerGitHub <noreply@github.com>2021-08-10 18:55:22 +0200
commitdce488d8f786cd3f67719196d21fbeca9c8bf688 (patch)
tree6c489f4bc1ff4411f343a7bcf95e0fb2bbff4c9c /core/input
parentd915c187d0caeaf392c055e880c001c5835eae51 (diff)
parenta0a019a99826d7afbe701a3157324e8ccc1edf80 (diff)
Merge pull request #49417 from Bhu1-V/gsoc-cmd-plt
Command Palette For Godot
Diffstat (limited to 'core/input')
-rw-r--r--core/input/input_event.cpp24
-rw-r--r--core/input/input_event.h16
2 files changed, 40 insertions, 0 deletions
diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp
index 4a2abffae8..1715fca9e8 100644
--- a/core/input/input_event.cpp
+++ b/core/input/input_event.cpp
@@ -32,6 +32,7 @@
#include "core/input/input_map.h"
#include "core/os/keyboard.h"
+#include "scene/gui/shortcut.h"
const int InputEvent::DEVICE_ID_TOUCH_MOUSE = -1;
const int InputEvent::DEVICE_ID_INTERNAL = -2;
@@ -1512,3 +1513,26 @@ void InputEventMIDI::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_number"), "set_controller_number", "get_controller_number");
ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_value"), "set_controller_value", "get_controller_value");
}
+
+///////////////////////////////////
+
+void InputEventShortcut::set_shortcut(Ref<Shortcut> p_shortcut) {
+ shortcut = p_shortcut;
+ emit_changed();
+}
+
+Ref<Shortcut> InputEventShortcut::get_shortcut() {
+ return shortcut;
+}
+
+bool InputEventShortcut::is_pressed() const {
+ return true;
+}
+
+String InputEventShortcut::as_text() const {
+ return vformat(RTR("Input Event with Shortcut=%s"), shortcut->get_as_text());
+}
+
+String InputEventShortcut::to_string() {
+ return vformat("InputEventShortcut: shortcut=%s", shortcut->get_as_text());
+}
diff --git a/core/input/input_event.h b/core/input/input_event.h
index 76a45c04a4..98d204fe13 100644
--- a/core/input/input_event.h
+++ b/core/input/input_event.h
@@ -42,6 +42,8 @@
* The events are pretty obvious.
*/
+class Shortcut;
+
/**
* Input Modifier Status
* for keyboard/mouse events.
@@ -538,4 +540,18 @@ public:
InputEventMIDI() {}
};
+class InputEventShortcut : public InputEvent {
+ GDCLASS(InputEventShortcut, InputEvent);
+
+ Ref<Shortcut> shortcut;
+
+public:
+ void set_shortcut(Ref<Shortcut> p_shortcut);
+ Ref<Shortcut> get_shortcut();
+ virtual bool is_pressed() const override;
+
+ virtual String as_text() const override;
+ virtual String to_string() override;
+};
+
#endif // INPUT_EVENT_H