I'm showing an NSAlert with a custom view and three buttons. The custom view has two text fields and it allows the user to log in.
In the Mac App Store, an NSAlert with a similar design comes up. When the user clicks the sign in button, the NSAlert does not dismiss (until the credentials are verified). How does Apple keep the alert up?
Get the NSButton
you want to behave differently. Change its target and action. (To call through to the original target/action, preserve them before you change them.)
NSAlert *alert = ...;
NSButton *button = [[alert buttons] objectAtIndex:...];
id oldTarget = [button target];
SEL oldAction = [button action];
[button setTarget:self];
[button setAction:@selector(verifyCredentials:)];
Alternatively, you may want to build the alert as a custom window controller and XIB (which is how Apple did it in the case of the App Store.) In that case, you have fine-grained control over button behaviour.
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