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 5:31 PM, Christiaan Hofman wrote:

> 
> On Feb 8, 2010, at 1:12, Chad Leigh -- ObjectWerks Inc wrote:
> 
>> 
>> On Feb 7, 2010, at 5:02 PM, Christiaan Hofman wrote:
>> 
>>> 
>>> On Feb 7, 2010, at 7:41, Chad Leigh -- ObjectWerks Inc wrote:
>>> 
>>>> Hi
>>>> 
>>>> I am having an issue with NSBeginAlertSheet() on 10.6.  (Don't know how or if it works or not on 10.5 with this iteration -- this app is in production with slightly different code on 10.5 without issue)
>>>> 
>>>> The code below lives in an object that sends a remote host a transaction and if the transaction returns an error it runs this Alert Sheet and previously (in the production code) the window passed in was [self mainWindow] which was a reference to the main app window.  I am now calling this object to do a transaction during a registration sequence and the window up is an auxiliary panel that captures registration info.  So I changed the window to be generically [NSApp keyWindow] as my thinking is that this should always use the correct window.
>>>> 
>>>> Now, when it is called it does in fact put the alert sheet up on the panel.  But the function ends immediately and does not wait for the user to hit OK.  
>>> 
>>> Actually, that particular aspect is exactly what it is supposed to do. Notice that the function has "Begin" in the name, not "Run" as the alert panel functions do.
>> 
>> 
>> I don't think so.  For one, everywhere else it runs the sheet and if you read the Apple docs it says that it creates and runs the sheet
> 
> The fact that a sheet is being run does not mean that this method waits till that's is finished. The fact that the function has callbacks should be a very clear indication that this method in fact does run the sheet async and returns immediately, if the word "Begin" was not clear enough. The fact is, whether you like it or not, that this function does return immediately. As does the related NSAlert method. 
> 
> I agree that the docs could be a bit more explicit, but I disagree that they say what you're expecting. Perhaps  this is related to the fact that Apple considers this API close to deprecated, and does not take this doc or possible problems in this API as a big priority. This is also a reason why I pointed out that fact. 


Ok, this gives me something to think about.  I need to see why it "works" elsewhere.  I wrote it all 6-7 years ago and am just getting back into it (and mostly just getting back into Cocoa) so I need to look at other similar places it is being used to see what is different.

Gracias!  And to Adam Maxwell as well

Chad
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.