From 82de61b0aae9ebf798ba4de7c1ff5e632a734246 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 6 Oct 2021 13:15:10 +0200 Subject: [PATCH] RichToolTips: Don't set a Timer for Tooltip but dismiss the tooltip when a mouse leave the button --- src/slic3r/GUI/Plater.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 845c79a6f..f00c6df3e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -27,7 +27,11 @@ #include #include #include +#ifdef _WIN32 #include +#include +#include +#endif #include "libslic3r/libslic3r.h" #include "libslic3r/Format/STL.hpp" @@ -624,6 +628,7 @@ struct Sidebar::priv #ifdef _WIN32 wxString btn_reslice_tip; void show_rich_tip(const wxString& tooltip, wxButton* btn); + void hide_rich_tip(wxButton* btn); #endif }; @@ -663,9 +668,18 @@ void Sidebar::priv::show_rich_tip(const wxString& tooltip, wxButton* btn) tip.SetTipKind(wxTipKind_BottomRight); tip.SetTitleFont(wxGetApp().normal_font()); tip.SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); - tip.SetTimeout(1200); tip.ShowFor(btn); } + +void Sidebar::priv::hide_rich_tip(wxButton* btn) +{ + auto children = btn->GetChildren(); + using wxRichToolTipPopup = wxCustomBackgroundWindow; + for (auto child : children) { + if (wxRichToolTipPopup* popup = dynamic_cast(child)) + popup->Dismiss(); + } +} #endif // Sidebar / public @@ -807,6 +821,10 @@ Sidebar::Sidebar(Plater *parent) p->show_rich_tip(tooltip, *btn); event.Skip(); }); + (*btn)->Bind(wxEVT_LEAVE_WINDOW, [btn, this](wxMouseEvent& event) { + p->hide_rich_tip(*btn); + event.Skip(); + }); #else (*btn)->SetToolTip(tooltip); #endif // _WIN32 @@ -874,6 +892,10 @@ Sidebar::Sidebar(Plater *parent) p->show_rich_tip(p->btn_reslice_tip, p->btn_reslice); event.Skip(); }); + p->btn_reslice->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& event) { + p->hide_rich_tip(p->btn_reslice); + event.Skip(); + }); #endif // _WIN32 p->btn_send_gcode->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { p->plater->send_gcode(); });