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?
atom
August 8, 2012, 7:12pm
2
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 ColourSelector ??
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.
jules
August 8, 2012, 7:28pm
4
Have you tried the pop-up colour selector in the introjucer’s colour editing panel? It uses a CalloutBox.
void xxxxx()
{
ColourSelector colourSelector;
colourSelector.set... (...);
colourSelector.addChangeListener (...);
CallOutBox callOut (colourSelector, *this, nullptr);
callOut.runModalLoop();
}
void changeListenerCallback (ChangeBroadcaster* source)
{
ColourSelector* cs = dynamic_cast <ColourSelector*> (source);
setColour (SomeComponentClass::xxxColourId, cs->getCurrentColour());
//...
}
leehu
May 10, 2017, 8:28am
6
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::backgrou…