diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-11-20 17:03:08 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-11-20 17:03:08 +0100 |
commit | 285954659dafd2461fb917120705f19170793fb1 (patch) | |
tree | 75d44610ba7b2cf8b9583d970a15e056bd15bb05 /scene/main | |
parent | 23fc8e22a3977a66351090fb1b56c72967e7cf09 (diff) | |
parent | be349fa6d35534f5fccb00a3cc7b1f2b46757eb9 (diff) | |
download | redot-engine-285954659dafd2461fb917120705f19170793fb1.tar.gz |
Merge pull request #96721 from aXu-AP/tooltip-distance
Fix tooltip appearing in old place, on movement
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/viewport.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index e70407f36e..b66cfb516a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1931,21 +1931,19 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { } } - // If the tooltip timer isn't running, start it. - // Otherwise, only reset the timer if the mouse has moved more than 5 pixels. - if (!is_tooltip_shown && over->can_process() && - (gui.tooltip_timer.is_null() || - Math::is_zero_approx(gui.tooltip_timer->get_time_left()) || - mm->get_relative().length() > 5.0)) { - if (gui.tooltip_timer.is_valid()) { - gui.tooltip_timer->release_connections(); - gui.tooltip_timer = Ref<SceneTreeTimer>(); + // Reset the timer if the mouse has moved more than 5 pixels or has entered a new control. + if (!is_tooltip_shown && over->can_process()) { + Vector2 new_tooltip_pos = over->get_screen_transform().xform(pos); + if (over != gui.tooltip_control || gui.tooltip_pos.distance_squared_to(new_tooltip_pos) > 25) { + if (gui.tooltip_timer.is_valid()) { + gui.tooltip_timer->release_connections(); + } + gui.tooltip_control = over; + gui.tooltip_pos = new_tooltip_pos; + gui.tooltip_timer = get_tree()->create_timer(gui.tooltip_delay); + gui.tooltip_timer->set_ignore_time_scale(true); + gui.tooltip_timer->connect("timeout", callable_mp(this, &Viewport::_gui_show_tooltip)); } - gui.tooltip_control = over; - gui.tooltip_pos = over->get_screen_transform().xform(pos); - gui.tooltip_timer = get_tree()->create_timer(gui.tooltip_delay); - gui.tooltip_timer->set_ignore_time_scale(true); - gui.tooltip_timer->connect("timeout", callable_mp(this, &Viewport::_gui_show_tooltip)); } } |