diff options
author | Bhuvan Vemula <bhuvanvemula@gmail.com> | 2021-05-29 18:58:16 +0530 |
---|---|---|
committer | Bhuvan Vemula <bhuvanvemula@gmail.com> | 2021-08-09 17:41:50 +0530 |
commit | a0a019a99826d7afbe701a3157324e8ccc1edf80 (patch) | |
tree | d691da471a230891c9274ef33e9ccd5c3c796270 /core | |
parent | 504eb48214d8c2e723923c9025eb4a38180e7ac0 (diff) |
Added EditorCommandPalette
Diffstat (limited to 'core')
-rw-r--r-- | core/input/input_event.cpp | 24 | ||||
-rw-r--r-- | core/input/input_event.h | 16 |
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 |