mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 16:22:21 +00:00
fixed #157. cmd+delete now triggers the delete action
This commit is contained in:
@@ -44,5 +44,11 @@ typedef NS_ENUM(NSUInteger, MPActionType) {
|
|||||||
* @return MPActionTpype for action, if no match was found MPUnknownAction is returned
|
* @return MPActionTpype for action, if no match was found MPUnknownAction is returned
|
||||||
*/
|
*/
|
||||||
+ (MPActionType)typeForAction:(SEL)action;
|
+ (MPActionType)typeForAction:(SEL)action;
|
||||||
|
/**
|
||||||
|
* Returns the key equivalent for the given action type
|
||||||
|
* @param type Action to get the equivalent for
|
||||||
|
* @return NSString containing the key equivalent for this action. If none is present, an empty NString is returned
|
||||||
|
*/
|
||||||
|
+ (NSString *)keyEquivalentForAction:(MPActionType)type;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -42,6 +42,17 @@
|
|||||||
return NSSelectorFromString(actionDict[@(type)]);
|
return NSSelectorFromString(actionDict[@(type)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSString *)keyEquivalentForAction:(MPActionType)type {
|
||||||
|
static NSDictionary *keyEquivalentDictionary;
|
||||||
|
static unichar backspaceCharacter = NSBackspaceCharacter;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
keyEquivalentDictionary = @{ @(MPActionDelete): [[NSString alloc] initWithCharacters:&backspaceCharacter length:1] };
|
||||||
|
});
|
||||||
|
NSString *keyEquivalent = keyEquivalentDictionary[@(type)];
|
||||||
|
return keyEquivalent ? keyEquivalent : @"";
|
||||||
|
}
|
||||||
|
|
||||||
+ (MPActionType)typeForAction:(SEL)action {
|
+ (MPActionType)typeForAction:(SEL)action {
|
||||||
NSString *selectorString = NSStringFromSelector(action);
|
NSString *selectorString = NSStringFromSelector(action);
|
||||||
NSArray *selectors = [[self _actionDictionary] allValues];
|
NSArray *selectors = [[self _actionDictionary] allValues];
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ static void MPContextmenuHelperBeginSection(NSMutableArray *items) {
|
|||||||
if(insertDelete) {
|
if(insertDelete) {
|
||||||
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
|
NSMenuItem *delete = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"")
|
||||||
action:[MPActionHelper actionOfType:MPActionDelete]
|
action:[MPActionHelper actionOfType:MPActionDelete]
|
||||||
keyEquivalent:@""];
|
keyEquivalent:[MPActionHelper keyEquivalentForAction:MPActionDelete]];
|
||||||
[items addObject:delete];
|
[items addObject:delete];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ NSString *const _MPTAbleSecurCellView = @"PasswordCell";
|
|||||||
MPDocument *document = [notification object];
|
MPDocument *document = [notification object];
|
||||||
|
|
||||||
if(!document.selectedGroup) {
|
if(!document.selectedGroup) {
|
||||||
/* No group, this only can happen in filtering, just return */
|
/* TODO: handle deleted item */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user