diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-09-13 20:42:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 20:42:55 +0200 |
commit | 32d93feebe473f5a2f63da3a4f39e81f10054ce9 (patch) | |
tree | 20f725458df6fb78e473e42260a678b027def6d7 | |
parent | e8ed2528915ace8b578e042c2f3a5db0c9a99bec (diff) | |
parent | e1cc70309c40dbb346208d2873269381b560ac8c (diff) |
Merge pull request #35168 from KoBeWi/sure²
Fix error when click edge of the tree icon
-rw-r--r-- | scene/gui/tree.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index cb990892ed..c4dfbc0d4e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2339,13 +2339,22 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int cache.click_type = Cache::CLICK_NONE; return -1; } + + // Make sure the click is correct. + Point2 click_pos = get_global_mouse_position() - get_global_position(); + if (!get_item_at_position(click_pos)) { + pressed_button = -1; + cache.click_type = Cache::CLICK_NONE; + return -1; + } + pressed_button = j; cache.click_type = Cache::CLICK_BUTTON; cache.click_index = j; cache.click_id = c.buttons[j].id; cache.click_item = p_item; cache.click_column = col; - cache.click_pos = get_global_mouse_position() - get_global_position(); + cache.click_pos = click_pos; update(); //emit_signal(SNAME("button_pressed")); return -1; |