diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-03-01 08:46:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-01 08:46:14 +0100 |
commit | 1b446ebcd4922f48e5d0e2cfbb53062ce58b060e (patch) | |
tree | 8db3ee8dffebe80806021cca7de8f1b83209aa9c | |
parent | 32209e4ebdba202b627f947e1365abd83ca4fc5c (diff) | |
parent | f2b0bd54b2fb079e4ec3d54fe9f9576b84c69b96 (diff) |
Merge pull request #58559 from fazil47/scene-tree-icon-focus
Double clicking scene tree icon focuses that node
-rw-r--r-- | scene/gui/tree.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 73cf2b9c6e..5afc37061b 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3286,8 +3286,21 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { } else { Rect2 rect = get_selected()->get_meta("__focus_rect"); Point2 mpos = b->get_position(); + int icon_size_x = 0; + Ref<Texture2D> icon = get_selected()->get_icon(selected_col); + if (icon.is_valid()) { + Rect2i icon_region = get_selected()->get_icon_region(selected_col); + if (icon_region == Rect2i()) { + icon_size_x = icon->get_width(); + } else { + icon_size_x = icon_region.size.width; + } + } + // Icon is treated as if it is outside of the rect so that double clicking on it will emit the item_double_clicked signal. if (rtl) { - mpos.x = get_size().width - mpos.x; + mpos.x = get_size().width - (mpos.x + icon_size_x); + } else { + mpos.x -= icon_size_x; } if (rect.has_point(mpos)) { if (!edit_selected()) { |