From 404e21cfa7e9d20b7afeac10675b61fab621eeec Mon Sep 17 00:00:00 2001 From: avenjamin Date: Mon, 9 Nov 2009 23:59:05 +0000 Subject: Set keyboard shortcut for Delete button in alert dialogs to command D. Set keyboard shortcut for Truncate button in alert dialog to command T --- Source/SPContentFilterManager.m | 11 ++++++----- Source/SPQueryFavoriteManager.m | 20 +++++++++++--------- Source/SPTableRelations.m | 9 +++++---- Source/TableDocument.m | 3 ++- Source/TableSource.m | 6 ++++-- Source/TablesList.m | 12 +++++++++--- 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/Source/SPContentFilterManager.m b/Source/SPContentFilterManager.m index d6a7f1e3..44e74ebc 100644 --- a/Source/SPContentFilterManager.m +++ b/Source/SPContentFilterManager.m @@ -270,8 +270,8 @@ - (IBAction)removeContentFilter:(id)sender { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Remove selected content filters?", @"remove selected content filters message") - defaultButton:NSLocalizedString(@"Cancel", @"cancel button") - alternateButton:NSLocalizedString(@"Remove", @"remove button") + defaultButton:NSLocalizedString(@"Remove", @"remove button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to remove all selected content filters? This action cannot be undone.", @"remove all selected content filters informative message")]; @@ -280,8 +280,9 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; - [[buttons objectAtIndex:1] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; + [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeSelectedFilters"]; } @@ -706,7 +707,7 @@ // } // } if([contextInfo isEqualToString:@"removeSelectedFilters"]) { - if (returnCode == NSAlertAlternateReturn) { + if (returnCode == NSAlertDefaultReturn) { NSIndexSet *indexes = [contentFilterTableView selectedRowIndexes]; // get last index diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m index 5a766853..e99706db 100644 --- a/Source/SPQueryFavoriteManager.m +++ b/Source/SPQueryFavoriteManager.m @@ -240,8 +240,8 @@ - (IBAction)removeQueryFavorite:(id)sender { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Remove selected query favorites?", @"remove selected query favorites message") - defaultButton:NSLocalizedString(@"Cancel", @"cancel button") - alternateButton:NSLocalizedString(@"Remove", @"remove button") + defaultButton:NSLocalizedString(@"Remove", @"remove button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to remove all selected query favorites? This action cannot be undone.", @"remove all selected query favorites informative message")]; @@ -250,8 +250,9 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; - [[buttons objectAtIndex:1] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; + [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeSelectedFavorites"]; } @@ -262,8 +263,8 @@ - (IBAction)removeAllQueryFavorites:(id)sender { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Remove all query favorites?", @"remove all query favorites message") - defaultButton:NSLocalizedString(@"Cancel", @"cancel button") - alternateButton:NSLocalizedString(@"Remove All", @"remove all button") + defaultButton:NSLocalizedString(@"Remove All", @"remove all button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to remove all of your saved query favorites? This action cannot be undone.", @"remove all query favorites informative message")]; @@ -272,8 +273,9 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@"\r"]; - [[buttons objectAtIndex:1] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; + [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:[self window] modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeAllFavorites"]; } @@ -672,7 +674,7 @@ // } // } if([contextInfo isEqualToString:@"removeSelectedFavorites"]) { - if (returnCode == NSAlertAlternateReturn) { + if (returnCode == NSAlertDefaultReturn) { NSIndexSet *indexes = [favoritesTableView selectedRowIndexes]; // get last index diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 1f37f8f7..d16838be 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -190,8 +190,8 @@ if ([relationsTableView numberOfSelectedRows] > 0) { NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Delete relation", @"delete relation message") - defaultButton:NSLocalizedString(@"Cancel", @"cancel button") - alternateButton:NSLocalizedString(@"Delete", @"delete button") + defaultButton:NSLocalizedString(@"Delete", @"delete button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:NSLocalizedString(@"Are you sure you want to delete the selected relations? This action cannot be undone.", @"delete selected relation informative message")]; @@ -200,7 +200,8 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:@"removeRelation"]; @@ -338,7 +339,7 @@ { if ([contextInfo isEqualToString:@"removeRelation"]) { - if (returnCode == NSAlertAlternateReturn) { + if (returnCode == NSAlertDefaultReturn) { NSString *thisTable = [tablesListInstance tableName]; NSIndexSet *selectedSet = [relationsTableView selectedRowIndexes]; diff --git a/Source/TableDocument.m b/Source/TableDocument.m index a8a71e8b..b0f11df2 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1027,7 +1027,8 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert setAlertStyle:NSCriticalAlertStyle]; diff --git a/Source/TableSource.m b/Source/TableSource.m index f09ff64b..4d89ddbf 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -358,7 +358,8 @@ reloads the table (performing a new mysql-query) NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removefield"]; @@ -387,7 +388,8 @@ reloads the table (performing a new mysql-query) NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; [alert beginSheetModalForWindow:tableWindow diff --git a/Source/TablesList.m b/Source/TablesList.m index e35b65e1..fbbd412c 100644 --- a/Source/TablesList.m +++ b/Source/TablesList.m @@ -299,7 +299,8 @@ NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"d"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; NSIndexSet *indexes = [tablesListView selectedRowIndexes]; @@ -456,14 +457,19 @@ [tableWindow endEditingFor:nil]; - NSAlert *alert = [NSAlert alertWithMessageText:@"" defaultButton:NSLocalizedString(@"Truncate", @"truncate button") alternateButton:NSLocalizedString(@"Cancel", @"cancel button") otherButton:nil informativeTextWithFormat:@""]; + NSAlert *alert = [NSAlert alertWithMessageText:@"" + defaultButton:NSLocalizedString(@"Truncate", @"truncate button") + alternateButton:NSLocalizedString(@"Cancel", @"cancel button") + otherButton:nil + informativeTextWithFormat:@""]; [alert setAlertStyle:NSCriticalAlertStyle]; NSArray *buttons = [alert buttons]; // Change the alert's cancel button to have the key equivalent of return - [[buttons objectAtIndex:0] setKeyEquivalent:@""]; + [[buttons objectAtIndex:0] setKeyEquivalent:@"t"]; + [[buttons objectAtIndex:0] setKeyEquivalentModifierMask:NSCommandKeyMask]; [[buttons objectAtIndex:1] setKeyEquivalent:@"\r"]; if ([tablesListView numberOfSelectedRows] == 1) { -- cgit v1.2.3