Assertion in Juce 5 that wasn't in 4

Hi, the following code:

CallOutBox callOut( m_colour_selector, rect, this );

causes an assertion when clicking outside the colour picker to dismiss it on the final line of:

void Component::grabKeyboardFocus()
// if component methods are being called from threads other than the message
// thread, you’ll need to use a MessageManagerLock object to make sure it’s thread-safe.

grabFocusInternal (focusChangedDirectly, true);

// A component can only be focused when it's actually on the screen!
// If this fails then you're probably trying to grab the focus before you've
// added the component to a parent or made it visible. Or maybe one of its parent
// components isn't yet visible.
jassert (isShowing() || isOnDesktop());


Checked back in 4.3.1 and this assertion not happening. Not sure if this is intentional or not?


Don’t use a modal loop unless you really need to! They’ll be deprecated at some point in the future, and especially if you’re writing a plugin, you MUST NOT do this!

If you look at the example of this in the juce demo, you’ll see it does this:

        ColourSelector* colourSelector = new ColourSelector();
        colourSelector->setName ("background");
        colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
        colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
        colourSelector->setSize (300, 400);

        CallOutBox::launchAsynchronously (colourSelector, button.getScreenBounds(), nullptr);

…and that works without a problem.

Hey Jules, thx for the update…

I actually took my solution from this post Easiest way to pop a dialog box with a ColourSelector? which is clearly out of date…