Alert Window ownership question


I’ll fully admit to an attack of the stupids, but I’m trying to understand the AlertWindow class. Here’s some example code:

[code] pAlertWindow = new AlertWindow(T(“Alert”), T(“Run for your life!”), AlertWindow::NoIcon);
pAlertWindow->addButton(T(“OK”), 0);

// Very ugly colors here
pAlertWindow->setColour(AlertWindow::backgroundColourId, Colour::Colour(0xff404040));
pAlertWindow->setColour(AlertWindow::textColourId, Colour::Colour(0xffff8080));
pAlertWindow->setColour(AlertWindow::outlineColourId, Colour::Colour(0xff000000));

// addChildComponent(pAlertWindow);


First of all, this is the main editor component for an audio plugin. Second, I’m running the 1.46 version of Juce. I have two questions related to this code

[list]If I add the alert window as a child component (by uncommenting it), it doesn’t seem to appear anywhere on my screen. In addtion, I can’t seem to attract its attention (it never exits the loop), so I have to halt the parent application. BTW, calling toFront doesn’t seem to make any difference.

The call to ‘runModalLoop’ makes the alert visible, but I seem to have to manually turn off visibility after the loop exits. I thought this was taken care of by the loop exit code.[/list]

I’m trying to attach this thing as a child component so that it will appear in the vicinity of the plugin window. Have I got my head wrapped around this wrong? Thanks for any nudges in the right direction.


I made some changes in the tip code recently to make this easier… Can’t really remember if there are obstacles to doing it with the 1.46 codebase.


I had used it this way

juce::AlertWindow *alert = new juce::AlertWindow (T("Enter the text"),T("DISC ID"), juce::AlertWindow::InfoIcon );
	alert->addButton (T("Continue"),1,juce::KeyPress(),juce::KeyPress());
	alert->addTextEditor (T("edit"),T(""),T("Disc Id"));
	alert->addToDesktop (4); 
	int returnValue = alert->runModalLoop();
       delete alert

You can see you have not set any bounds for it nor have you made it visible.