Search code examples
objective-cmacoscocoansbuttonnsalert

How to get focus ring off an NSAlert button?


Is there any way that you can take away the focus ring of the NSAlert button. Here is what I mean:

Focus ring annoyingly appears on NSAlert button

Here is my code:

[NSApp activateIgnoringOtherApps:YES];
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"Quit"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Warning!"];
[alert setInformativeText:@"How do you solve this question?"];
[alert setAlertStyle:NSWarningAlertStyle];
[alert beginSheetModalForWindow:nil modalDelegate:self didEndSelector:@selector(someMethodDidEnd:returnCode:contextInfo:) contextInfo:nil];

Solution

  • I would say you should not do this at all, this will go against apple guidelines.