Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made "Show Node in Tree" button more user friendly #83761

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2857,7 +2857,16 @@ void EditorPropertyNodePath::_menu_option(int p_idx) {
Node *target_node = edited_node->get_node_or_null(np);
ERR_FAIL_NULL(target_node);

SceneTreeDock *scene_tree_dock = SceneTreeDock::get_singleton();
if (scene_tree_dock->get_window() == get_tree()->get_root()) {
TabContainer *tab_container = (TabContainer *)scene_tree_dock->get_parent_control();
tab_container->set_current_tab(tab_container->get_tab_idx_from_control(scene_tree_dock));
} else {
scene_tree_dock->get_window()->grab_focus();
}

SceneTreeDock::get_singleton()->set_selected(target_node);
SceneTreeDock::get_singleton()->get_tree_editor()->update_tree();
} break;
}
}
Expand Down Expand Up @@ -2893,6 +2902,18 @@ const NodePath EditorPropertyNodePath::_get_node_path() const {
}
}

void EditorPropertyNodePath::_button_input(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;

if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == MouseButton::RIGHT) {
menu->show_popup();

Vector2 pos = menu->get_popup()->get_position();
pos.x += mb->get_position().x - assign->get_size().x;
menu->get_popup()->set_position(pos);
}
}

bool EditorPropertyNodePath::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
return !is_read_only() && is_drop_valid(p_data);
}
Expand Down Expand Up @@ -3028,6 +3049,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
assign->set_auto_translate(false);
assign->set_expand_icon(true);
assign->connect("pressed", callable_mp(this, &EditorPropertyNodePath::_node_assign));
assign->connect("gui_input", callable_mp(this, &EditorPropertyNodePath::_button_input));
SET_DRAG_FORWARDING_CD(assign, EditorPropertyNodePath);
hbc->add_child(assign);

Expand Down
1 change: 1 addition & 0 deletions editor/editor_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ class EditorPropertyNodePath : public EditorProperty {
void _accept_text();
void _text_submitted(const String &p_text);
const NodePath _get_node_path() const;
void _button_input(const Ref<InputEvent> &p_event);

bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
Expand Down
Loading