Hi,
i successfully integrated a text editor in an alert window using Juce 5.4.7, Mac:
juce::AlertWindow myAl(“title:”, “message”, juce::AlertWindow::InfoIcon);
myAl.addTextEditor(“password”, “”, “”);
myAl.showAsync();
In Juce6.1.4, it doesn’t work any more, as showAsync() now needs arguments like MessageBoxOptions. But MessageBoxOptions doesn’t allow to add a text editor.
What to do?
Thank you
Thomas
reuk
March 28, 2022, 10:16am
2
It looks to me like you should be able to do something similar by creating the AlertWindow on the heap, and then calling enterModalState
on it:
auto* window = new juce::AlertWindow ("title:", "message", juce::AlertWindow::InfoIcon);
window->addTextEditor ("password", "", "");
window->setAlwaysOnTop (true);
window->enterModalState (true, nullptr, true);
t0m
March 28, 2022, 11:02am
3
There’s an example in JUCE DemoRunner:
{
auto colourSelector = std::make_unique<ColourSelector>();
colourSelector->setName ("background");
colourSelector->setCurrentColour (findColour (TextButton::buttonColourId));
colourSelector->setColour (ColourSelector::backgroundColourId, Colours::transparentBlack);
colourSelector->setSize (300, 400);
CallOutBox::launchAsynchronously (std::move (colourSelector), button.getScreenBounds(), nullptr);
}
else if (type == extraComponentsAlertWindow)
{
asyncAlertWindow = std::make_unique<AlertWindow> ("AlertWindow demo..",
"This AlertWindow has a couple of extra components added to show how to add drop-down lists and text entry boxes.",
MessageBoxIconType::QuestionIcon);
asyncAlertWindow->addTextEditor ("text", "enter some text here", "text field:");
asyncAlertWindow->addComboBox ("option", { "option 1", "option 2", "option 3", "option 4" }, "some options");
asyncAlertWindow->addButton ("OK", 1, KeyPress (KeyPress::returnKey, 0, 0));
asyncAlertWindow->addButton ("Cancel", 0, KeyPress (KeyPress::escapeKey, 0, 0));