Re: NSBeginAlertSheet not waiting for button to be pushed
Chad Leigh -- ObjectWerks Inc <chad+macosx-AU1NHruoRJaEK/[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Feb 7, 2010, at 11:26 AM, Kyle Sluder wrote: > On Sun, Feb 7, 2010 at 8:23 AM, Chad Leigh -- ObjectWerks Inc > <chad+macosx-AU1NHruoRJaEK/[email protected]> wrote: >>> You shouldn't be using that in Cocoa apps for a very long time now, use the NSAlert class. >> >> It is not marked as deprecated. > > Please see Using Alert Sheets in Sheet Programming Topics for Cocoa > <http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/Sheets/Tasks/UsingAlertSheets.html>: > > "You can use the Application Kit’s functional API for alert sheets, or > you can use the methods of the NSAlert class. The latter approach is > recommended for applications built for Mac OS X v10.3 and later" I have read that. As your quote said, "You can use the Application Kit's functional API for alert sheets." It is not deprecated and fully supported at the moment. Most of this app's code is from 2003 and this bit dates from that time. I am just modifying a little where it gets called from with a new set of registration panels. Do you have any ideas on why it may not be modal and wait for the OK button? What might be the cause of that? > >> Definitely yes. The key window will always be the window that generated the request in my particular app. > > No it won't. You can make no guarantee to this effect. There are > system panels such as the Character Viewer which can become key. Not in this app. Those panels cannot trigger the call that includes this particular alert sheet and the keyWindow call. The utility function that is being called is in a non GUI library and makes a network call that can fail or return an error code from the remote server. This utility class has no clue what the current window is. However, it is only called by my apps windows, so to speak, and will never be called when some other window like a system panel is up. It cannot be triggered that way. > > You should always explicitly choose the window which displays the sheet. I am explicitly choosing the window as best as the routine knows which is the keyWindow. Chad > > --Kyle Sluder