Modal Dialog Window Closing?


#1

I have a modal Dialog window that opens with a component doing some operations, created as:

How can I close this modalDialog after its finished doing its stuff? Do I have to do this from the parent that called it, can I do it with the component that resides inside this modaldialog?


#2

Just call exitModalState on the top-level component and it’ll exit the modal loop.


#3

Im calling exitModalState(1) after the operation is complete, but its not closing the actual dialog window?


#4

You have to call it on the thing that’s actually modal. In this case, it’s the dialog window itself, I think.


#5

Im calling it from the actual modal dialog window:

[code]URL theurl(someurlwithimage);

InputStream *input = theurl.createInputStream(true);

Image* im = ImageFileFormat::loadFrom(*input);

streamedimage = new Image (Image::RGB, im->getWidth(), im->getHeight(), true);
Graphics g (*streamedimage);
g.fillAll (Colours::white);
g.drawImageAt(im, 0, 0, false);
delete im;

exitModalState(1);
[/code]

Which works ok, streams the image but I want this modal window to close after its done this. exitModalState here seems to have no effect?


#6

ok, this works

have a couple more questions:
1-is there a way to track the streamed data so I can include a progress bar while loading?
2-after image is done streaming how can I pass this to my parent component that called this modal dialog?
3- im testing this by streaming some images from the web, some work others seem to crash the app, and they are the correct image format?


#7

getTopLevelComponent()->exitModalState would be better (there might be another modal comp active when you call that, or none)

The Image stuff doesn’t currently have any progress, mainly because it’s usually so quick. What you could write would be a custom stream that relays the data from your real stream, but which keeps track of how much has been sent.

Where does it crash? If you’re sure it’s a juce bug that’s crashing, and not your own code, then maybe forward me some links to the problem images and I’ll check them out.


#8