From aa07828503c500e7da8770b0b41a4308fd23c3d6 Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Wed, 15 May 2024 17:28:58 -0400 Subject: [PATCH] Fix tooltip mouse position conversion for scaled controls Viewport used get_global_transform().xform_inv(mpos) to convert the mouse position to the control's local coordinates when getting the control's tooltip, which does not handle scale correctly. This impacted tooltips for any controls that depended on the position to determine what tooltip to show, including RichTextLabel, ItemList, Tree, and probably some others. This change is for Viewport to use get_global_transform_with_canvas().affine_inverse().xform(mpos) for tooltips instead, to match what we do for Viewport::_gui_call_input. Fixes #91984 --- scene/main/viewport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 26128a08ab3a..d6dd87166400 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1429,7 +1429,7 @@ void Viewport::_gui_show_tooltip() { Control *tooltip_owner = nullptr; gui.tooltip_text = _gui_get_tooltip( gui.tooltip_control, - gui.tooltip_control->get_global_transform().xform_inv(gui.last_mouse_pos), + gui.tooltip_control->get_global_transform_with_canvas().affine_inverse().xform(gui.last_mouse_pos), &tooltip_owner); gui.tooltip_text = gui.tooltip_text.strip_edges(); @@ -1909,7 +1909,7 @@ void Viewport::_gui_input_event(Ref p_event) { if (gui.tooltip_popup) { if (gui.tooltip_control) { - String tooltip = _gui_get_tooltip(over, gui.tooltip_control->get_global_transform().xform_inv(mpos)); + String tooltip = _gui_get_tooltip(over, gui.tooltip_control->get_global_transform_with_canvas().affine_inverse().xform(mpos)); tooltip = tooltip.strip_edges(); if (tooltip.is_empty() || tooltip != gui.tooltip_text) {