diff options
author | Spartan322 <Megacake1234@gmail.com> | 2024-11-20 16:20:16 -0500 |
---|---|---|
committer | Spartan322 <Megacake1234@gmail.com> | 2024-11-20 18:02:42 -0500 |
commit | 9857e4762b8d076259c4be863ba9f53df306d940 (patch) | |
tree | b03c5b5de96e29ffb7e1b008912d21aba5629bc5 /scene/main | |
parent | fd9045fe09e9bea691f0169c16d45cbebddb6bba (diff) | |
parent | 9e6098432aac35bae42c9089a29ba2a80320d823 (diff) | |
download | redot-engine-9857e4762b8d076259c4be863ba9f53df306d940.tar.gz |
Merge commit godotengine/godot@9e6098432aac35bae42c9089a29ba2a80320d823
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 8a48b99040..dabd1dbe07 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1938,21 +1938,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)); } } |