Showing all tooltips in same place (by using a Label?)

Hi All,

I’m not sure if this is the best way to achieve this behaviour, is there any other easier way?

I’m trying to setup a Label that shows the tooltip for whatever component the mouse is over so the text always shows in the same place. Additionally I also want to clear the text if the mouse is not over any Component.
My fist try has been creating a custom LookAndFeel that stores a pointer to a label and in his drawTooltip method it just sets the text on that label.

I’m having some issues as it shows some weird stuff depending on the position of the mouse over the object (as you can see in the image).

Screenshot (22)

// hint Label
addAndMakeVisible(hint);
hint.setJustificationType(Justification::topLeft);
hint.setBounds(480, 20, 150, 100);

MyLookAndFeel mlf = new MyLookAndFeel(&hint);
// Tooltipwindow tt{this, 0} 
tt.setLookAndFeel(mlf);

Hi Marc, did you ever find a solution to this?

What we do is that we setup a timer and do it manually

    void timerCallback()
    {
      juce::Component* const underMouse = juce::Desktop::getInstance().getMainMouseSource().getComponentUnderMouse();
      juce::TooltipClient* const ttc = dynamic_cast <juce::TooltipClient*> (underMouse);

      juce::String toolTip;
      if (ttc != 0 && !(underMouse->isMouseButtonDown() || underMouse->isCurrentlyBlockedByAnotherModalComponent()))
        toolTip = ttc->getTooltip();

      mpTooltip->setText(toolTip, juce::dontSendNotification);
    }

Check how TooltipWindow is implemented

2 Likes