Revision: 29289 http://sourceforge.net/p/bibdesk/svn/29289 Author: hofman Date: 2025-07-17 22:28:30 +0000 (Thu, 17 Jul 2025) Log Message: ----------- separate validating text view editing and showing error
Modified Paths: -------------- trunk/bibdesk/BDSKEditor.m Modified: trunk/bibdesk/BDSKEditor.m =================================================================== --- trunk/bibdesk/BDSKEditor.m 2025-07-17 21:21:34 UTC (rev 29288) +++ trunk/bibdesk/BDSKEditor.m 2025-07-17 22:28:30 UTC (rev 29289) @@ -347,20 +347,28 @@ return YES; } -- (BOOL)validateCurrentEditedView +- (BOOL)validateCurrentEditedViewAndReturnError:(NSError **)error { NSParameterAssert(currentEditedView); BOOL rv = ([[currentEditedView string] isStringTeXQuotingBalancedWithBraces:YES connected:NO]); - if (NO == rv) { - NSAlert *alert = [[NSAlert alloc] init]; - [alert setMessageText:NSLocalizedString(@"Invalid Value", @"Message in alert dialog when entering an invalid value")]; - [alert setInformativeText:NSLocalizedString(@"The value you entered contains unbalanced braces and cannot be saved.", @"Informative text in alert dialog")]; - - [alert beginSheetModalForWindow:[self window] completionHandler:NULL]; + if (NO == rv && error) { + NSError *err = [NSError mutableLocalErrorWithCode:kBDSKFailedToCommit localizedDescription:NSLocalizedString(@"Invalid Value", @"Message in alert dialog when entering an invalid value")]; + [err setValue:NSLocalizedString(@"The value you entered contains unbalanced braces and cannot be saved.", @"Informative text in alert dialog") forKey:NSLocalizedRecoverySuggestionErrorKey]; + *error = err; } return rv; } +- (BOOL)validateCurrentEditedView +{ + NSParameterAssert(currentEditedView); + NSError *error = nil; + BOOL rv = [self validateCurrentEditedViewAndReturnError:&error]; + if (NO == rv && error) + [self presentError:error modalForWindow:[self window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; + return rv; +} + - (void)discardEditing { if (editorFlags.isEditing == NO) @@ -490,16 +498,9 @@ if (NO == [self control:textField isValidObject:obj error:error]) return NO; - } else if (currentEditedView && [self validateCurrentEditedView] == NO) { + } else if (currentEditedView && [self validateCurrentEditedViewAndReturnError:error] == NO) { // the string of the edited textView has unbalanced braces - - if (error) { - NSError *err = [NSError mutableLocalErrorWithCode:kBDSKFailedToCommit localizedDescription:NSLocalizedString(@"Failed to commit edits", @"Error message")]; - [err setValue:NSLocalizedString(@"The value you entered contains unbalanced braces and cannot be saved.", @"Informative text in alert dialog") forKey:NSLocalizedRecoverySuggestionErrorKey]; - *error = err; - } return NO; - } // commit should now succeed without errors @@ -2315,7 +2316,7 @@ // this is called multiple times when switching tabs if (currentEditedView) { - NSParameterAssert([self validateCurrentEditedView]); + NSParameterAssert([self validateCurrentEditedViewAndReturnError:NULL]); currentEditedView = nil; [self setPreviousValueForCurrentEditedNotesView:nil]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit