Right way to make a blocking Options dialog box?


#1

I’m trying to figure out the right way to make a dialog box that displays a custom component and for the life of me, i just can’t get it to show up. What’s the right way to create a dialog box that has a customized view (possibly a TreeView? ) that will block interaction with the main app window, similar to how AlertWindows operate?

This code here shows the popup but it doesn’t put this custom component inside the AlertWindow dialog box.

customComponent = new CustomComponent();
AlertWindow::showOkCancelBox(AlertWindow::AlertIconType::NoIcon, 
    "CustomView", "", "Select", "Cancel", customComponent);

I didn’t see an example in the JuceDemo that has this behavior… Think of the “Bounce Session” window in Logic…


#2

You can add your component to the alert window using AlertWindow::addCustomComponent()

ScopedPointer<Component> customComponent = new CustomComponent();
ScopedPointer<AlertWindow> alert = new AlertWindow ("CustomView", "", AlertWindow::AlertIconType::NoIcon);
alert->addCustomComponent (customComponent);
alert->addButton ("Select", 1);
alert->addButton ("Cancel", 0);
alert->runModalLoop();
if (alert->runModalLoop() == 1) {
    // [...]
}

See the details for the class AlertWindow.
But it should be noted, that this behaviour in a plugin should be avoided at all cost:

  1. when a session is loaded, these kind of popups will give a bad user experience
  2. imagine you are rolling a recording and a plugin runs a modal dialog stopping you from operating your DAW…

HTH


#3

Daniel is right, don’t do that.

You might can use a non-modal window, which is opened from your plugin-gui, and ALWAYS closed before your plugin GUI is closed, which has a setAlwaysOnTop(true) setting. But never ever use a modal dialog, which relies on the fact that other user interaction is blocked.


#4

I’m using this in a stand alone app, so blocking or running modally is fine.