Return button's index for [NSAlert runModalSheetForWindow].
This commit is contained in:
parent
b9455a997c
commit
a897d5b715
1 changed files with 17 additions and 32 deletions
|
@ -40,22 +40,7 @@
|
|||
#pragma mark Private methods
|
||||
|
||||
-(IBAction) BE_stopSynchronousSheet:(id)sender {
|
||||
// See which of the buttons was clicked
|
||||
NSUInteger clickedButtonIndex = [[self buttons] indexOfObject:sender];
|
||||
|
||||
// Be consistent with Apple's documentation (see NSAlert's addButtonWithTitle) so that
|
||||
// the fourth button is numbered NSAlertThirdButtonReturn + 1, and so on
|
||||
NSInteger modalCode = 0;
|
||||
if (clickedButtonIndex == NSAlertFirstButtonReturn)
|
||||
modalCode = NSAlertFirstButtonReturn;
|
||||
else if (clickedButtonIndex == NSAlertSecondButtonReturn)
|
||||
modalCode = NSAlertSecondButtonReturn;
|
||||
else if (clickedButtonIndex == NSAlertThirdButtonReturn)
|
||||
modalCode = NSAlertThirdButtonReturn;
|
||||
else
|
||||
modalCode = NSAlertThirdButtonReturn + (clickedButtonIndex - 2);
|
||||
|
||||
[NSApp stopModalWithCode:modalCode];
|
||||
[NSApp stopModalWithCode:[sender tag]];
|
||||
}
|
||||
|
||||
-(void) BE_beginSheetModalForWindow:(NSWindow *)aWindow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue