Figured out a way to fix event propagation for shortcuts and some other cases so they properly stop shortcuts if a modal window is open, closes #4848
This commit is contained in:
parent
972c2ad09f
commit
ba5bc57816
|
@ -31,6 +31,7 @@
|
|||
#include "print_string.h"
|
||||
#include "button_group.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
void BaseButton::_input_event(InputEvent p_event) {
|
||||
|
||||
|
@ -416,6 +417,10 @@ Ref<ShortCut> BaseButton:: get_shortcut() const {
|
|||
void BaseButton::_unhandled_input(InputEvent p_event) {
|
||||
|
||||
if (!is_disabled() && is_visible() && shortcut.is_valid() && shortcut->is_shortcut(p_event)) {
|
||||
|
||||
if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
|
||||
return; //ignore because of modal window
|
||||
|
||||
if (is_toggle_mode()) {
|
||||
set_pressed(!is_pressed());
|
||||
emit_signal("toggled",is_pressed());
|
||||
|
|
|
@ -2502,6 +2502,9 @@ Variant Viewport::gui_get_drag_data() const {
|
|||
return gui.drag_data;
|
||||
}
|
||||
|
||||
Control *Viewport::get_modal_stack_top() const {
|
||||
return gui.modal_stack.size()?gui.modal_stack.back()->get():NULL;
|
||||
}
|
||||
|
||||
String Viewport::get_configuration_warning() const {
|
||||
|
||||
|
|
|
@ -374,6 +374,7 @@ public:
|
|||
bool gui_has_modal_stack() const;
|
||||
|
||||
Variant gui_get_drag_data() const;
|
||||
Control *get_modal_stack_top() const;
|
||||
|
||||
virtual String get_configuration_warning() const;
|
||||
|
||||
|
|
|
@ -168,6 +168,10 @@ void EditorNode::_update_title() {
|
|||
|
||||
void EditorNode::_unhandled_input(const InputEvent& p_event) {
|
||||
|
||||
if (Node::get_viewport()->get_modal_stack_top())
|
||||
return; //ignore because of modal window
|
||||
|
||||
|
||||
if (p_event.type==InputEvent::KEY && p_event.key.pressed && !p_event.key.echo && !gui_base->get_viewport()->gui_has_modal_stack()) {
|
||||
|
||||
|
||||
|
|
|
@ -39,16 +39,20 @@
|
|||
#include "multi_node_edit.h"
|
||||
#include "tools/editor/plugins/animation_player_editor_plugin.h"
|
||||
#include "animation_editor.h"
|
||||
|
||||
#include "scene/main/viewport.h"
|
||||
|
||||
|
||||
|
||||
void SceneTreeDock::_unhandled_key_input(InputEvent p_event) {
|
||||
|
||||
if (get_viewport()->get_modal_stack_top())
|
||||
return; //ignore because of modal window
|
||||
|
||||
uint32_t sc = p_event.key.get_scancode_with_modifiers();
|
||||
if (!p_event.key.pressed || p_event.key.echo)
|
||||
return;
|
||||
|
||||
|
||||
if (ED_IS_SHORTCUT("scene_tree/add_child_node", p_event)) {
|
||||
_tool_selected(TOOL_NEW);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue