Re: NSBeginAlertSheet not waiting for button to be pushed

Christiaan Hofman <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
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.

Christiaan

> This is true with "nil" passed in for the did-end selector or a selector being passed in.  If I pass a selector in, that selector is not called.

> Any ideas?  
> 
> Thanks
> Chad
> 
> 
>             NSBeginAlertSheet(
>                [reply objectForKey:@"errorMessage"],
>                                        // sheet message
>                @"OK",              // default button label
>                nil,                    // no third button
>                nil,              //no  other button label
>                [NSApp keyWindow],                 // window sheet is attached to
>                self,                   // we will be our own delegate
>                @selector(sheetDidEnd:returnCode:contextInfo:),
>                                        // did-end selector
>                NULL,                   // no need for did-dismiss selector
>                nil,                 // context info
>                [NSString stringWithFormat:@"message with code %@", [reply objectForKey:@"errorCode"]]);
>                                        // additional text
>
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.