Is there a way to open a NSAlert window, set a delegate for didEnd callback and while the alert is shown, all other windows should be "disabled" (can the window itself but not push any button or change any text)?
Asked
Active
Viewed 638 times
1 Answers
1
In your NSAlert code add
NSModalSession session = [NSApp beginModalSessionForWindow:theWindow];
[NSApp runModalSession:session];
// NSAlert stuff here ...
In your didEnd callback add
[NSApp endModalSession:session];
For more information about modal windows read NSApplication's "Managing the Event Loop" section.
Update:
Here is a sample code from Apple's doc showing how to run modal without callbacks.
NSModalSession session = [NSApp beginModalSessionForWindow:theWindow];
for (;;) {
if ([NSApp runModalSession:session] != NSRunContinuesResponse)
break;
[self doSomeWork];
}
[NSApp endModalSession:session];

cocoafan
- 4,884
- 4
- 37
- 45
-
Is there to do it without having to add code to the didEnd callback? – Erik Sapir Jun 15 '11 at 10:39