Reputation: 4553
In Cocoa, is it possible to present a window modally as a window (not as a sheet) only with respect specifically to one other window? In particular, I would like to present an alert that prevents the user from interacting only with the window about which it is informing the user (until of course the user has dealt with--closed--the alert). While the user is prevented from interacting with the window specified in the call to present the alert, she is able to continue interacting with other windows. I'll reiterate: in this case presenting the alert as a sheet is not an admissible solution.
Upvotes: 0
Views: 125
Reputation: 126127
Sheets are the standard method for making one window modal with respect to another -- especially for alerts -- so Apple does not provide convenient API for doing this some other way. Ask yourself:
If you really want to make a window modal to another without using the sheet API, implementing it is just a matter of considering what "window modal" means... which it seems you've already done:
... an alert that prevents the user from interacting only with the window ...
So what you really need to do is prevent the user from interacting with that window. There are many ways to do this, including:
NSApplication
and override sendEvent:
to ignore events in the window (this is really overkill and potentially problematic)In addition to that, you probably want to attach your alert to the window so they move together and don't do weird things in Exposé: see -[NSWindow addChildWindow:ordered:]
.
Upvotes: 1