Skip to content

Commit

Permalink
Add refreshTooltip to TooltipLabelUpdater
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-13 committed Feb 15, 2024
1 parent 0bb7d38 commit 7efcfd5
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions WECore/CoreJUCEPlugin/TooltipLabelUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<juce::TooltipClient*>(component);

if (tooltipClient != nullptr) {
const juce::String displayString = tooltipClient->getTooltip().isEmpty() ? _defaultString : tooltipClient->getTooltip();
_targetLabel->setText(displayString, juce::dontSendNotification);
}
}
}
}

0 comments on commit 7efcfd5

Please sign in to comment.