From 033deacfdc4faf3026df9b1eb957901dfcd76866 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Thu, 1 Mar 2018 15:13:47 +0100 Subject: [PATCH] pressing down in search input will focus entries (#707) --- MacPass/MPContextBarViewController.m | 8 +++--- MacPass/MPEntryViewController.m | 40 +++++++--------------------- MacPass/MPToolbarDelegate.m | 4 +-- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/MacPass/MPContextBarViewController.m b/MacPass/MPContextBarViewController.m index 8b5ef2cd..d5ea5dc3 100644 --- a/MacPass/MPContextBarViewController.m +++ b/MacPass/MPContextBarViewController.m @@ -109,10 +109,10 @@ typedef NS_ENUM(NSUInteger, MPContextTab) { #pragma mark MPDocument Notifications - (void)registerNotificationsForDocument:(MPDocument *)document { - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateFilterButtons) name:MPDocumentDidChangeSearchFlags object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_showEntryHistory:) name:MPDocumentShowEntryHistoryNotification object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didChangeCurrentItem:) name:MPDocumentCurrentItemChangedNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_updateFilterButtons) name:MPDocumentDidChangeSearchFlags object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_showEntryHistory:) name:MPDocumentShowEntryHistoryNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didChangeCurrentItem:) name:MPDocumentCurrentItemChangedNotification object:document]; } - (void)_didEnterSearch:(NSNotification *)notification { diff --git a/MacPass/MPEntryViewController.m b/MacPass/MPEntryViewController.m index 3eb96069..93b9e7e0 100644 --- a/MacPass/MPEntryViewController.m +++ b/MacPass/MPEntryViewController.m @@ -212,37 +212,15 @@ NSString *const _MPTableSecurCellView = @"PasswordCell"; } - (void)registerNotificationsForDocument:(MPDocument *)document { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didChangeCurrentItem:) - name:MPDocumentCurrentItemChangedNotification - object:document]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didAddItem:) - name:MPDocumentDidAddEntryNotification - object:document]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didEnterSearch:) - name:MPDocumentDidEnterSearchNotification - object:document]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didExitSearch:) - name:MPDocumentDidExitSearchNotification - object:document]; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didUpdateSearchResults:) - name:MPDocumentDidChangeSearchResults - object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(_didUnlockDatabase:) - name:MPDocumentDidUnlockDatabaseNotification - object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_showEntryHistory:) name:MPDocumentShowEntryHistoryNotification object:document]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_hideEntryHistory:) name:MPDocumentHideEntryHistoryNotification object:document]; - + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didChangeCurrentItem:) name:MPDocumentCurrentItemChangedNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didAddItem:) name:MPDocumentDidAddEntryNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didEnterSearch:) name:MPDocumentDidEnterSearchNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didExitSearch:) name:MPDocumentDidExitSearchNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUpdateSearchResults:) name:MPDocumentDidChangeSearchResults object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_didUnlockDatabase:) name:MPDocumentDidUnlockDatabaseNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_showEntryHistory:) name:MPDocumentShowEntryHistoryNotification object:document]; + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(_hideEntryHistory:) name:MPDocumentHideEntryHistoryNotification object:document]; + [self.contextBarViewController registerNotificationsForDocument:document]; } diff --git a/MacPass/MPToolbarDelegate.m b/MacPass/MPToolbarDelegate.m index d13eacfa..c14110a6 100644 --- a/MacPass/MPToolbarDelegate.m +++ b/MacPass/MPToolbarDelegate.m @@ -94,7 +94,7 @@ NSString *const MPToolbarItemHistory = @"TOOLBAR_HISTORY"; } - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; + [NSNotificationCenter.defaultCenter removeObserver:self]; } @@ -227,7 +227,7 @@ NSString *const MPToolbarItemHistory = @"TOOLBAR_HISTORY"; #pragma mark - NSSearchFieldDelegate - (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector { - if(commandSelector == @selector(insertNewline:)) { + if(commandSelector == @selector(insertNewline:) || commandSelector == @selector(moveDown:)) { [[NSApp targetForAction:@selector(focusEntries:) to:nil from:self] focusEntries:self]; } return NO;