Design a dialog with projucer


#1

Hi,

is there a way for easily designing a dialog box with Projucer, as I would do for a JUCE application window?.

I have a an app (not created with Projucer) and I need to design some relatively complex dialog box, and doing it by adding buttons, menus…placing them manually seems to be unpleasant task…

Thanks
NAthaniel


#2

Shouldn’t be any different from a normal window. Just use “Add new GUI Component…” from within the Projucer, modify your GUI and then load it with the DialogWindow class.

For example, if your GUI component is called DialogBox, then you could do this:

 DialogWindow::LaunchOptions myDialog;
 myDialog.content.set (new DialogBox, true);
 int returnValue = myDialog.runModal();
 DBG (returnValue);

Or without using modal loops:

    struct DialogCallback : ModalComponentManager::Callback
    {
        void modalStateFinished (int returnValue) override
        {
            DBG (returnValue);
        }
    };
    
    DialogWindow::LaunchOptions myDialog;
    myDialog.content.set (new DialogBox, true);
    ModalComponentManager::getInstance()->attachCallback (myDialog.launchAsync(), new DialogCallback);