began work for seamless editing with history support

This commit is contained in:
michael starke
2016-08-25 18:02:19 +02:00
parent b7357e2e43
commit 2958f5255b
14 changed files with 121 additions and 105 deletions

View File

@@ -268,6 +268,15 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
MPPasswordCreatorViewController *viewController = [[MPPasswordCreatorViewController alloc] init];
viewController.allowsEntryDefaults = YES;
viewController.representedObject = self.representedObject;
viewController.completionHandler = ^void (NSModalResponse response, NSString *password) {
/* TODO mark for modification! */
self.generatePasswordButton.enabled = YES;
/* We should only use the password if there is actually one */
if(password.length > 0) {
self.representedEntry.password = password;
}
};
[self _showPopopver:viewController atView:self.passwordTextField onEdge:NSMinYEdge];
}
@@ -285,18 +294,6 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
}
- (void)popoverDidClose:(NSNotification *)notification {
/* We do not enable the button all the time, but it's working find this way */
[self.generatePasswordButton setEnabled:YES];
NSPopover *popover = notification.object;
id controller = _activePopover.contentViewController;
/* Check for password wizzard */
if([controller respondsToSelector:@selector(generatedPassword)]) {
NSString *password = [controller generatedPassword];
/* We should only use the password if there is actually one */
if(password.length > 0) {
self.representedEntry.password = [controller generatedPassword];
}
}
self.activePopover = nil;
}
@@ -437,21 +434,6 @@ static NSString *kMPContentBindingString3 = @"content.%@.%@.%@";
options:nil];
}
- (void)_toggleEditing:(BOOL)edit {
NSArray <NSTextField *> *textFields = @[self.titleTextField,
self.usernameTextField,
self.URLTextField,
self.passwordTextField,
self.tagsTokenField
/*self.createdTextField,
self.modifiedTextField*/
];
for(NSTextField *t in textFields) {
t.editable = edit;
t.selectable = edit;
}
}
#pragma mark -
#pragma mark MPDocument Notifications