Is it possible to display a NSAlert/NSAlertPanel over a model window

448 Views Asked by At

I am displaying a model window using runModelForWindow,I have an button in this model window,whenever user clicks on this button,I need to display an alert panel without closing the model window.Is it possible?I have tried displaying NSAlertPanel,it is going behind the model window,so that user can't see it.Please give me some suggestion how can I do this?

1

There are 1 best solutions below

0
On BEST ANSWER

After using the following two lines before running my alert panel brought alert on top of model window.

ProcessSerialNumber psn = {0, kCurrentProcess};
TransformProcessType(&psn, kProcessTransformToForegroundApplication);

NSAlert *alert = [NSAlert alertWithMessageText: @"Alert Text" defaultButton: @"OK" alternateButton: @"Cancel" otherButton: nil informativeTextWithFormat: @""];

NSInteger alertRetVal =[alert runModal];