diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index 5b938a3314..f7c2326529 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -832,10 +832,14 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D } if (mb->is_pressed()) { - Node3DEditorViewport::NavigationScheme nav_scheme = (Node3DEditorViewport::NavigationScheme)EDITOR_GET("editors/3d/navigation/navigation_scheme").operator int(); - if ((nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA || nav_scheme == Node3DEditorViewport::NAVIGATION_MODO) && mb->is_alt_pressed()) { - input_action = INPUT_NONE; - } else if (mb->get_button_index() == MouseButton::LEFT) { + if (mb->get_button_index() == MouseButton::LEFT) { + Node3DEditorViewport::NavigationScheme nav_scheme = (Node3DEditorViewport::NavigationScheme)EDITOR_GET("editors/3d/navigation/navigation_scheme").operator int(); + if ((nav_scheme == Node3DEditorViewport::NAVIGATION_MAYA || nav_scheme == Node3DEditorViewport::NAVIGATION_MODO) && mb->is_alt_pressed()) { + return EditorPlugin::AFTER_GUI_INPUT_PASS; + } + + valid_mb_press = true; + bool can_edit = (node && node->get_mesh_library().is_valid()); if (input_action == INPUT_PASTE) { _do_paste(); @@ -862,6 +866,9 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D return EditorPlugin::AFTER_GUI_INPUT_STOP; } else if (selection.active) { _set_selection(false); + if (input_action == INPUT_SELECT) { + input_action = INPUT_NONE; + } return EditorPlugin::AFTER_GUI_INPUT_STOP; } } else { @@ -896,22 +903,21 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D return EditorPlugin::AFTER_GUI_INPUT_PASS; } - if (mb->get_button_index() == MouseButton::LEFT && input_action == INPUT_SELECT) { - EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); - undo_redo->create_action(TTR("GridMap Selection")); - undo_redo->add_do_method(this, "_set_selection", selection.active, selection.begin, selection.end); - undo_redo->add_undo_method(this, "_set_selection", last_selection.active, last_selection.begin, last_selection.end); - undo_redo->commit_action(); - } + if (valid_mb_press && mb->get_button_index() == MouseButton::LEFT) { + valid_mb_press = false; - if (mb->get_button_index() == MouseButton::LEFT && input_action != INPUT_NONE) { - set_items.clear(); - input_action = INPUT_NONE; - return EditorPlugin::AFTER_GUI_INPUT_STOP; - } - if (mb->get_button_index() == MouseButton::RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_PASTE)) { - input_action = INPUT_NONE; - return EditorPlugin::AFTER_GUI_INPUT_STOP; + if (input_action == INPUT_SELECT) { + EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton(); + undo_redo->create_action(TTR("GridMap Selection")); + undo_redo->add_do_method(this, "_set_selection", selection.active, selection.begin, selection.end); + undo_redo->add_undo_method(this, "_set_selection", last_selection.active, last_selection.begin, last_selection.end); + undo_redo->commit_action(); + } + if (input_action != INPUT_NONE) { + set_items.clear(); + input_action = INPUT_NONE; + return EditorPlugin::AFTER_GUI_INPUT_STOP; + } } } } diff --git a/modules/gridmap/editor/grid_map_editor_plugin.h b/modules/gridmap/editor/grid_map_editor_plugin.h index cf40cd8a32..88cd669ad5 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.h +++ b/modules/gridmap/editor/grid_map_editor_plugin.h @@ -69,6 +69,7 @@ class GridMapEditor : public EditorDock { }; InputAction input_action = INPUT_NONE; + bool valid_mb_press = false; Panel *panel = nullptr; MenuButton *options = nullptr; SpinBox *floor = nullptr;