From 1e7b9c509f02dd641f10fe50d24bb19c165078d7 Mon Sep 17 00:00:00 2001 From: Jaroslaw Filiochowski Date: Mon, 18 Jul 2016 22:14:57 +0200 Subject: [PATCH 1/2] Don't start a new tooltip timer for the same tooltip --- scene/main/viewport.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index bb6e6e289b9..9d2b0cfccfd 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2007,8 +2007,16 @@ void Viewport::_gui_input_event(InputEvent p_event) { } + bool is_tooltip_shown = false; - if (can_tooltip) { + if (can_tooltip && gui.tooltip_popup) { + String tooltip = over->get_tooltip(gui.tooltip->get_global_transform().xform_inv(mpos)); + + if (gui.tooltip_popup && tooltip == gui.tooltip_label->get_text()) + is_tooltip_shown = true; + } + + if (can_tooltip && !is_tooltip_shown) { gui.tooltip=over; gui.tooltip_pos=mpos;//(parent_xform * get_transform()).affine_inverse().xform(pos); From be560a750c363355ad077331bf6bdbc62c6b2762 Mon Sep 17 00:00:00 2001 From: Jaroslaw Filiochowski Date: Tue, 19 Jul 2016 06:27:12 +0200 Subject: [PATCH 2/2] Hide tooltip if new mouse position's tooltip is empty --- scene/main/viewport.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 9d2b0cfccfd..cf84f8f4251 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -2009,11 +2009,17 @@ void Viewport::_gui_input_event(InputEvent p_event) { bool is_tooltip_shown = false; - if (can_tooltip && gui.tooltip_popup) { - String tooltip = over->get_tooltip(gui.tooltip->get_global_transform().xform_inv(mpos)); + if (gui.tooltip_popup) { + if (can_tooltip) { + String tooltip = over->get_tooltip(gui.tooltip->get_global_transform().xform_inv(mpos)); - if (gui.tooltip_popup && tooltip == gui.tooltip_label->get_text()) - is_tooltip_shown = true; + if (tooltip.length() == 0) + _gui_cancel_tooltip(); + else if (tooltip == gui.tooltip_label->get_text()) + is_tooltip_shown = true; + } + else + _gui_cancel_tooltip(); } if (can_tooltip && !is_tooltip_shown) {