From 6b0423b1914f68a67c523b2aee059e8ffeeeca11 Mon Sep 17 00:00:00 2001 From: neikeq Date: Thu, 19 Nov 2015 15:47:04 +0100 Subject: [PATCH] Show select menu on button pressed (instead of released) --- .../plugins/canvas_item_editor_plugin.cpp | 2 +- .../editor/plugins/spatial_editor_plugin.cpp | 102 +++++++++--------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 1b80431e67e..5a871da9ddf 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -987,7 +987,7 @@ void CanvasItemEditor::_viewport_input_event(const InputEvent& p_event) { if (b.button_index==BUTTON_RIGHT) { - if (!b.pressed && tool==TOOL_SELECT && b.mod.alt) { + if (b.pressed && tool==TOOL_SELECT && b.mod.alt) { Point2 click=Point2(b.x,b.y); diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 14ddad318f6..b39975dc848 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -862,6 +862,57 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { //VisualServer::get_singleton()->instance_set_transform(cursor_instance,Transform(Matrix3(),cursor.cursor_pos)); } } + + if (b.mod.alt) { + + if (nav_scheme == NAVIGATION_MAYA) + break; + + _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift); + + clicked_wants_append=b.mod.shift; + + if (selection_results.size() == 1) { + + clicked=selection_results[0].item->get_instance_ID(); + selection_results.clear(); + + if (clicked) { + _select_clicked(clicked_wants_append,true); + clicked=0; + } + + } else if (!selection_results.empty()) { + + NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); + StringName root_name = root_path.get_name(root_path.get_name_count()-1); + + for (int i = 0; i < selection_results.size(); i++) { + + Spatial *spat=selection_results[i].item; + + Ref icon; + if (spat->has_meta("_editor_icon")) + icon=spat->get_meta("_editor_icon"); + else + icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons"); + + String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path()); + + selection_menu->add_item(spat->get_name()); + selection_menu->set_item_icon(i, icon ); + selection_menu->set_item_metadata(i, node_path); + selection_menu->set_item_tooltip(i,String(spat->get_name())+ + "\nType: "+spat->get_type()+"\nPath: "+node_path); + } + + selection_menu->set_global_pos(Vector2( b.global_x, b.global_y )); + selection_menu->popup(); + selection_menu->call_deferred("grab_click_focus"); + + break; + } + } } if (_edit.mode!=TRANSFORM_NONE && b.pressed) { @@ -888,57 +939,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) { //VisualServer::get_singleton()->poly_clear(indicators); set_message("Transform Aborted.",3); } - - if (!b.pressed && (spatial_editor->get_tool_mode()==SpatialEditor::TOOL_MODE_SELECT && b.mod.alt)) { - - if (nav_scheme == NAVIGATION_MAYA) - break; - - _find_items_at_pos(Vector2( b.x, b.y ),clicked_includes_current,selection_results,b.mod.shift); - - clicked_wants_append=b.mod.shift; - - if (selection_results.size() == 1) { - - clicked=selection_results[0].item->get_instance_ID(); - selection_results.clear(); - - if (clicked) { - _select_clicked(clicked_wants_append,true); - clicked=0; - } - - } else if (!selection_results.empty()) { - - NodePath root_path = get_tree()->get_edited_scene_root()->get_path(); - StringName root_name = root_path.get_name(root_path.get_name_count()-1); - - for (int i = 0; i < selection_results.size(); i++) { - - Spatial *spat=selection_results[i].item; - - Ref icon; - if (spat->has_meta("_editor_icon")) - icon=spat->get_meta("_editor_icon"); - else - icon=get_icon( has_icon(spat->get_type(),"EditorIcons")?spat->get_type():String("Object"),"EditorIcons"); - - String node_path="/"+root_name+"/"+root_path.rel_path_to(spat->get_path()); - - selection_menu->add_item(spat->get_name()); - selection_menu->set_item_icon(i, icon ); - selection_menu->set_item_metadata(i, node_path); - selection_menu->set_item_tooltip(i,String(spat->get_name())+ - "\nType: "+spat->get_type()+"\nPath: "+node_path); - } - - selection_menu->set_global_pos(Vector2( b.global_x, b.global_y )); - selection_menu->popup(); - selection_menu->call_deferred("grab_click_focus"); - - break; - } - } } break; case BUTTON_MIDDLE: {