summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-05-28 12:07:06 +0200
committerGitHub <noreply@github.com>2019-05-28 12:07:06 +0200
commit8384582828d38ebc8f4ab4c68b9ae5181d1e99dc (patch)
treef90b96eb2d7f2765080b7700844c5958a2390d2c
parentb546591d1bc9b0a10fa13c31397367cccb62b8cf (diff)
parent36bdf789274ca5b8daf41fddf5f5d05471812c1e (diff)
Merge pull request #27836 from turtletooth/right-click
Allow Right Click in Empty Space on FileSystemDock
-rw-r--r--editor/filesystem_dock.cpp14
-rw-r--r--editor/filesystem_dock.h1
-rw-r--r--scene/gui/tree.cpp4
3 files changed, 19 insertions, 0 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 52ed94e428..194a131095 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2160,6 +2160,18 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
}
}
+void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) {
+ // Right click is pressed in the empty space of the tree
+ path = "res://";
+ tree_popup->clear();
+ tree_popup->set_size(Size2(1, 1));
+ tree_popup->add_item(TTR("New Folder..."), FILE_NEW_FOLDER);
+ tree_popup->add_item(TTR("New Script..."), FILE_NEW_SCRIPT);
+ tree_popup->add_item(TTR("New Resource..."), FILE_NEW_RESOURCE);
+ tree_popup->set_position(tree->get_global_position() + p_pos);
+ tree_popup->popup();
+}
+
void FileSystemDock::_tree_empty_selected() {
tree->deselect_all();
}
@@ -2353,6 +2365,7 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_file_list_rmb_option", "option"), &FileSystemDock::_file_list_rmb_option);
ClassDB::bind_method(D_METHOD("_file_list_rmb_select"), &FileSystemDock::_file_list_rmb_select);
ClassDB::bind_method(D_METHOD("_file_list_rmb_pressed"), &FileSystemDock::_file_list_rmb_pressed);
+ ClassDB::bind_method(D_METHOD("_tree_rmb_empty"), &FileSystemDock::_tree_rmb_empty);
ClassDB::bind_method(D_METHOD("_file_deleted"), &FileSystemDock::_file_deleted);
ClassDB::bind_method(D_METHOD("_folder_deleted"), &FileSystemDock::_folder_deleted);
@@ -2485,6 +2498,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
tree->connect("item_activated", this, "_tree_activate_file");
tree->connect("multi_selected", this, "_tree_multi_selected");
tree->connect("item_rmb_selected", this, "_tree_rmb_select");
+ tree->connect("empty_rmb", this, "_tree_rmb_empty");
tree->connect("nothing_selected", this, "_tree_empty_selected");
tree->connect("gui_input", this, "_tree_gui_input");
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 9d20544ac2..978235b328 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -236,6 +236,7 @@ private:
void _file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options = true);
void _tree_rmb_select(const Vector2 &p_pos);
+ void _tree_rmb_empty(const Vector2 &p_pos);
void _file_list_rmb_select(int p_item, const Vector2 &p_pos);
void _file_list_rmb_pressed(const Vector2 &p_pos);
void _tree_empty_selected();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 049cae9dd9..e5313061da 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1970,6 +1970,9 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
item_h += child_h;
}
}
+ if (p_item == root && p_button == BUTTON_RIGHT) {
+ emit_signal("empty_rmb", get_local_mouse_position());
+ }
}
return item_h; // nothing found
@@ -3853,6 +3856,7 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("cell_selected"));
ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected")));
ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
+ ADD_SIGNAL(MethodInfo("empty_rmb", PropertyInfo(Variant::VECTOR2, "position")));
ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
ADD_SIGNAL(MethodInfo("item_edited"));
ADD_SIGNAL(MethodInfo("item_rmb_edited"));