What’s the easiest way to pop a dialog box that contains, as its content component, a
ColourSelector with OK and Cancel buttons that call Component::exitModalState with the appropriate value (the colour will be transmitted using the ModalComponentManager::Callback)?
Is there a general solution or do I have to roll a
DocumentWindow-derived class every time?
DialogWindow::showModalDialog() used to work for me, but what i’m seeing now, Dialog windows are not in style.
Yeah but I still have to roll my own DocumentWindow…is there no easier way to use the
And then how do I get the Colour? By the time the modal state ends, the dialog box is destroyed and the only thing I get back is an int.
Have you tried the pop-up colour selector in the introjucer’s colour editing panel? It uses a CalloutBox.
CallOutBox callOut (colourSelector, *this, nullptr);
void changeListenerCallback (ChangeBroadcaster* source)
ColourSelector* cs = dynamic_cast <ColourSelector*> (source);
setColour (SomeComponentClass::xxxColourId, cs->getCurrentColour());
Just in case anyone else finds this link, correct calling is noted here:
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::backgr…