diff --git a/WECore/CoreJUCEPlugin/TooltipLabelUpdater.h b/WECore/CoreJUCEPlugin/TooltipLabelUpdater.h index 1b02306..e965f68 100644 --- a/WECore/CoreJUCEPlugin/TooltipLabelUpdater.h +++ b/WECore/CoreJUCEPlugin/TooltipLabelUpdater.h @@ -54,8 +54,10 @@ namespace WECore::JUCEPlugin { */ void stop() { _targetLabel = nullptr; } - inline virtual void mouseEnter(const juce::MouseEvent &event) override; - inline virtual void mouseExit(const juce::MouseEvent &event) override; + inline virtual void mouseEnter(const juce::MouseEvent& event) override; + inline virtual void mouseExit(const juce::MouseEvent& event) override; + + inline void refreshTooltip(juce::Component* component); private: juce::Label* _targetLabel; @@ -127,4 +129,15 @@ namespace WECore::JUCEPlugin { _targetLabel->setText(_defaultString, juce::dontSendNotification); } } + + void TooltipLabelUpdater::refreshTooltip(juce::Component* component) { + if (_targetLabel != nullptr) { + juce::TooltipClient* tooltipClient = dynamic_cast(component); + + if (tooltipClient != nullptr) { + const juce::String displayString = tooltipClient->getTooltip().isEmpty() ? _defaultString : tooltipClient->getTooltip(); + _targetLabel->setText(displayString, juce::dontSendNotification); + } + } + } }