In chooser lists, treat deleteToBeginningOfLine: as delete:

This is only if there is a responder for the delete: action and is done to allow ⌘⌫ to be used to delete items in the list (like favorites).

The implementation is not ideal as we make assumptions about what action the ⌘⌫ key is bound to and perhaps it’s also a gotcha that ⌘⌫ in a text field will delete something else (though the list is also drawn as having focus).
This commit is contained in:
Allan Odgaard
2014-02-07 17:31:04 +07:00
parent 13f6c312a2
commit d1265913df

View File

@@ -48,7 +48,9 @@
- (BOOL)control:(NSControl*)aControl textView:(NSTextView*)aTextView doCommandBySelector:(SEL)aCommand
{
static auto const forward = new std::set<SEL>{ @selector(moveUp:), @selector(moveDown:), @selector(moveUpAndModifySelection:), @selector(moveDownAndModifySelection:), @selector(pageUp:), @selector(pageDown:), @selector(movePageUp:), @selector(movePageDown:), @selector(scrollPageUp:), @selector(scrollPageDown:), @selector(moveToBeginningOfDocument:), @selector(moveToEndOfDocument:), @selector(scrollToBeginningOfDocument:), @selector(scrollToEndOfDocument:), @selector(insertNewline:), @selector(insertNewlineIgnoringFieldEditor:), @selector(cancelOperation:) };
if(forward->find(aCommand) != forward->end() && [self respondsToSelector:aCommand])
if(aCommand == @selector(deleteToBeginningOfLine:) && [aControl.window tryToPerform:@selector(delete:) with:aControl])
return YES;
else if(forward->find(aCommand) != forward->end() && [self respondsToSelector:aCommand])
return [NSApp sendAction:aCommand to:self from:aControl];
return NO;
}