FR: TooltipWindow disable()

At the moment I am using a TooltipWindow via a smart pointer, so to disable it I delete it, and to enable it I std::make_unique a new one into existence. It would be a nicer API to have TooltipWindow::disable() and TooltipWindow::enable(). At the moment it seems to be assumed that tooltips are always just on.

Is this a valid request, or am I doing it wrong?

Here is a workaround :wink:

  class CKToolTipWindow : public TooltipWindow
    {
    public:
        CKToolTipWindow (Component* parentComponent)
            : TooltipWindow (parentComponent)

                  {};

        String getTipFor (Component& c) override
        {
            if (isActive)
                return TooltipWindow::getTipFor (c);

            return String();
        };

        void setIsActive (bool isActive_)
        {
            isActive = isActive_;
            if (! isActive)
                hideTip();
        };

    private:
        bool isActive = true;
    };
1 Like

This is certainly a good workaround. Straight up stopping the timer under the hood would help me sleep better at night, though! :sweat_smile:

I disagree - an RAII interface like that is much nicer.

It makes it much clearer to say the window doesn’t exist than it is to say it’s disabled. That’s a little ambiguous, especially since JUCE components already have an enabled flag that does something different.

1 Like

I’m starting to agree with this view, now that you’ve said it. Perhaps the docs should be updated to put first time users into the right mindset.