Thanks. I agree with what you say, however HOW to run the modal loop asynchronously isn't obvious. I used the "enterModalState" method, is it correct?
Anyway, I managed to get something to work, but I think it is not very clean, because I can't get rid of the raw pointers. If I use std::unique_ptrs, it crashes at some point. This is the working version with raw pointers:
class Myclass
{
// Arg, raw pointers ahead!!
AlertWindow* alertWindow;
AlertWindowCallback* alertWindowCallback; // Derives from ModalComponentManager::Callback
void Myclass::onRenameButtonClicked() noexcept
{
// Let's create our modal window and instantiate its callback.
alertWindow = new AlertWindow(..., AlertWindow::QuestionIcon);
// Adds custom fields.
alertWindow->addTextEditor(...);
alertWindow->addButton(...);
alertWindow->addButton(...);
alertWindowCallback = new AlertWindowCallback(*this);
// Is this the right way to show a modal window??
alertWindow->enterModalState(true, alertWindowCallback, true);
}
...
}
It works, however like I said, there are raw pointers.
The problem is that if I use std::unique_ptrs, it crashes. That is I guess because of the last parameter of "enterModalState" set to true, to let Juce destroying the objects. But if I put it to false, the program crashes *on exiting*, stating that I leaked resources (which was just why I wanted to use unique_ptr!)...
It may come from the way I dismiss the AlertWindow in the callback (I use "removeFromDesktop", is it correct)?
Thanks!
Julien.