From acbe3471285b24821d520ef7e800bb5fab405e60 Mon Sep 17 00:00:00 2001 From: Jakey Date: Wed, 4 Jul 2018 13:49:01 +0800 Subject: [PATCH] Real Time Search --- .../ProfilesManagerViewController.m | 4 +- .../ProfilesManagerWindowController.m | 28 ++++++++++++++ .../ProfilesManagerWindowController.xib | 38 +++++++++---------- ProfilesManager/Info.plist | 2 +- 4 files changed, 50 insertions(+), 22 deletions(-) diff --git a/ProfilesManager/Controller/ProfilesManagerViewController.m b/ProfilesManager/Controller/ProfilesManagerViewController.m index 1ed32a2..31d2f3b 100755 --- a/ProfilesManager/Controller/ProfilesManagerViewController.m +++ b/ProfilesManager/Controller/ProfilesManagerViewController.m @@ -84,8 +84,8 @@ - (void)loadProfileFilesWithSearchWord:(NSString*)searchWord { dic[@"filePath"] = [_profileDir stringByAppendingString:fileName?:@""]; if (dic && fileName) { - if (searchWord && searchWord.length>0) { - if ([plistString rangeOfString:searchWord].location != NSNotFound) { + if ([searchWord lowercaseString] && searchWord.length>0) { + if ([[plistString lowercaseString] rangeOfString:[searchWord lowercaseString]].location != NSNotFound) { provisions[fileName] = dic; } }else{ diff --git a/ProfilesManager/Controller/ProfilesManagerWindowController.m b/ProfilesManager/Controller/ProfilesManagerWindowController.m index 9963664..f8f4eff 100644 --- a/ProfilesManager/Controller/ProfilesManagerWindowController.m +++ b/ProfilesManager/Controller/ProfilesManagerWindowController.m @@ -23,7 +23,35 @@ - (void)windowDidLoad { - (IBAction)searchTypePopUpButtonTouched:(id)sender { } +- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector +{ +// NSLog(@"Selector method is (%@)", NSStringFromSelector( commandSelector ) ); + if (commandSelector == @selector(insertNewline:)) { + //Do something against ENTER key + [self searchButtonTouched:self.searchButton]; + return YES; + } +// else if (commandSelector == @selector(deleteForward:)) { +// //Do something against DELETE key +// +// } else if (commandSelector == @selector(deleteBackward:)) { +// //Do something against BACKSPACE key +// +// } else if (commandSelector == @selector(insertTab:)) { +// //Do something against TAB key +// } + return NO; + // return YES if the action was handled; otherwise NO +} +#pragma mark -- text field delegate +- (void)controlTextDidEndEditing:(NSNotification *)obj{ + [self searchButtonTouched:self.searchButton]; +} + +- (void)controlTextDidChange:(NSNotification *)obj{ + [self searchButtonTouched:self.searchButton]; +} - (IBAction)searchButtonTouched:(id)sender { ProfilesManagerViewController *manger = (ProfilesManagerViewController*)self.contentViewController; [manger loadProfileFilesWithSearchWord:self.searchTextField.stringValue]; diff --git a/ProfilesManager/Controller/ProfilesManagerWindowController.xib b/ProfilesManager/Controller/ProfilesManagerWindowController.xib index e04f238..5b3c943 100644 --- a/ProfilesManager/Controller/ProfilesManagerWindowController.xib +++ b/ProfilesManager/Controller/ProfilesManagerWindowController.xib @@ -8,7 +8,6 @@ - @@ -28,34 +27,35 @@ - + - - - + + + + - - - + + + - + + + + @@ -66,14 +66,14 @@ + - - + diff --git a/ProfilesManager/Info.plist b/ProfilesManager/Info.plist index 075e067..61b6139 100755 --- a/ProfilesManager/Info.plist +++ b/ProfilesManager/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleSignature ???? CFBundleVersion