From a0a019a99826d7afbe701a3157324e8ccc1edf80 Mon Sep 17 00:00:00 2001 From: Bhuvan Vemula Date: Sat, 29 May 2021 18:58:16 +0530 Subject: Added EditorCommandPalette --- core/input/input_event.cpp | 24 ++++++++++++++++++++++++ core/input/input_event.h | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'core/input') 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 p_shortcut) { + shortcut = p_shortcut; + emit_changed(); +} + +Ref 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; + +public: + void set_shortcut(Ref p_shortcut); + Ref get_shortcut(); + virtual bool is_pressed() const override; + + virtual String as_text() const override; + virtual String to_string() override; +}; + #endif // INPUT_EVENT_H -- cgit v1.2.3