TL;DR:
I created an AlertWindow :
juce::AlertWindow offlineDeviceAlert(“Could not fetch parameter”, “Device offline…”, juce::AlertWindow::InfoIcon);
and I run that in Modal mode using:
offlineDeviceAlert.runModalLoop();
Now I want to stop or remove the modal AlertWindow. How can I acheive this?
Long story:
I’m trying to stop the user from clicking on the main window when a device is offline and they’re trying to access the parameters of that device. So my messy solution is to always put a message saying that the device parameter can’t be accessed at that time. I create and display the message right before a blocking call which checks for the device parameter and then I want to delete/remove the message once the call returns.
What is the best way to do this?
You can close all modal components using ModalComponentManager::getInstance()->cancelAllModalComponents ();.
Have a look at ModalComponentManager for further information.
I put that right after runModalLoop() but that doesn’t seem to help. The alert window just stays there as a modal window. I can exit it on Windows by right clicking on the modal window and then quitting but what I want to do is for that window to disappear when I’m done with it. What am I missing here?
Yup, I was reluctant to use it in the first place but then it was the only thing that was giving me any results. I’ve changed around a few things now and this combination seems to work better:
juce::AlertWindow offlineDeviceAlert("Could not fetch parameter", "Device offline...", juce::AlertWindow::InfoIcon);
offlineDeviceAlert.setVisible(true);
offlineDeviceAlert.enterModalState();
and then after that long callback, I have this:
offlineDeviceAlert.setVisible(false);
ModalComponentManager::getInstance()->cancelAllModalComponents();
This has produced the best result so far. The AlertWindow now lingers when there is a long timeout but it doesn’t come to the front of the app and doesn’t show content. Getting closer to solution though so that’s progress.