I am currently displaying a modal window by using this code:
[[NSApplication sharedApplication] runModalForWindow:mainWindow];
However, when I close this window, the other windows are still inactive. How do I run the stopModal
method when the window is closed using the "red x"?
Thank you,
Michael
You can create a delegate for the window and have it respond to either the
-(void)windowWillClose:(NSNotification *)notification or the
- (void)windowShouldClose:(NSNotification *)notification methods like so:
- (void)windowWillClose:(NSNotification *)notification {
[[NSApplication sharedApplication] stopModal];
}
See Mac Dev Center: NSWindowDelegate Protocol Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With