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
This commit is contained in:
parent
9f4dbc6456
commit
aa07828503
|
@ -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<InputEvent> 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) {
|
||||
|
|
Loading…
Reference in New Issue