mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 03:32:40 +00:00
Merge pull request #218 from jamesrhurst/issue203
Make selected textfield end editing when a save will occur (fixes #203)
This commit is contained in:
@@ -40,6 +40,8 @@ APPKIT_EXTERN NSString *const MPDocumentDidUnlockDatabaseNotification;
|
||||
|
||||
APPKIT_EXTERN NSString *const MPDocumentCurrentItemChangedNotification;
|
||||
|
||||
APPKIT_EXTERN NSString *const MPDocumentWillSaveNotification;
|
||||
|
||||
/* Keys used in userInfo NSDictionaries on notifications */
|
||||
APPKIT_EXTERN NSString *const MPDocumentEntryKey;
|
||||
APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
|
||||
@@ -56,6 +56,8 @@ NSString *const MPDocumentDidUnlockDatabaseNotification = @"com.hicknhack.macp
|
||||
|
||||
NSString *const MPDocumentCurrentItemChangedNotification = @"com.hicknhack.macpass.MPDocumentCurrentItemChangedNotification";
|
||||
|
||||
NSString *const MPDocumentWillSaveNotification = @"com.hicknhack.macpass.MPDocumentWillSaveNotification";
|
||||
|
||||
NSString *const MPDocumentEntryKey = @"MPDocumentEntryKey";
|
||||
NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
|
||||
@@ -140,10 +142,12 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey
|
||||
}
|
||||
|
||||
- (void)saveDocumentAs:(id)sender {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillSaveNotification object:self];
|
||||
[super saveDocumentAs:sender];
|
||||
}
|
||||
|
||||
- (void)saveDocument:(id)sender {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:MPDocumentWillSaveNotification object:self];
|
||||
[super saveDocument:sender];
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,12 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_didAddEntry:)
|
||||
name:MPDocumentDidAddEntryNotification
|
||||
object:document];
|
||||
object:document];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(_willSave:)
|
||||
name:MPDocumentWillSaveNotification
|
||||
object:document];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
@@ -439,4 +444,9 @@ typedef NS_ENUM(NSUInteger, MPEntryTab) {
|
||||
[self.titleTextField becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_willSave:(NSNotification *)notification {
|
||||
// Force selected textfield to end editing
|
||||
[[[self view] window] makeFirstResponder:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user