Revision: 29292 http://sourceforge.net/p/bibdesk/svn/29292 Author: hofman Date: 2025-07-18 09:41:38 +0000 (Fri, 18 Jul 2025) Log Message: ----------- rename method like deleegate method
Modified Paths: -------------- trunk/bibdesk/BDSKEditor.m Modified: trunk/bibdesk/BDSKEditor.m =================================================================== --- trunk/bibdesk/BDSKEditor.m 2025-07-18 09:21:33 UTC (rev 29291) +++ trunk/bibdesk/BDSKEditor.m 2025-07-18 09:41:38 UTC (rev 29292) @@ -126,6 +126,7 @@ - (BOOL)control:(NSControl *)control didFailToFormatString:(NSString *)string errorDescription:(NSString *)errorString error:(NSError **)error; - (BOOL)control:(NSControl *)control isValidObject:(id)obj error:(NSError **)error; +- (BOOL)textShouldEndEditing:(NSText *)aTextObject error:(NSError **)error; - (void)recordChangingField:(NSString *)fieldName toValue:(NSString *)value; @@ -347,17 +348,6 @@ return YES; } -- (BOOL)validateCurrentEditedViewAndReturnError:(NSError **)error { - NSParameterAssert(currentEditedView); - BOOL rv = ([[currentEditedView string] isStringTeXQuotingBalancedWithBraces:YES connected:NO]); - 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; -} - - (void)discardEditing { if (editorFlags.isEditing == NO) return; @@ -482,7 +472,7 @@ if (NO == [self control:textField isValidObject:obj error:error]) return NO; - } else if (currentEditedView && [self validateCurrentEditedViewAndReturnError:error] == NO) { + } else if (currentEditedView && [self textShouldEndEditing:textView error:error] == NO) { // the string of the edited textView has unbalanced braces return NO; } @@ -2269,16 +2259,28 @@ return [self commitEditing]; } + +- (BOOL)textShouldEndEditing:(NSText *)aTextObject error:(NSError **)error { + BDSKASSERT(aTextObject == currentEditedView); + BOOL rv = ([[currentEditedView string] isStringTeXQuotingBalancedWithBraces:YES connected:NO]); + 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)textShouldEndEditing:(NSText *)aTextObject { BDSKASSERT(aTextObject == currentEditedView); - BOOL isValid = YES; + BOOL rv = YES; if (aTextObject == currentEditedView) { NSError *error = nil; - isValid = [self validateCurrentEditedViewAndReturnError:&error]; - if (NO == isValid && error) + rv = [self textShouldEndEditing:aTextObject error:&error]; + if (NO == rv && error) [self presentError:error modalForWindow:[self window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; } - return isValid; + return rv; } // sent by the textViews @@ -2303,7 +2305,7 @@ // this is called multiple times when switching tabs if (currentEditedView) { - NSParameterAssert([self validateCurrentEditedViewAndReturnError:NULL]); + NSParameterAssert([self textShouldEndEditing:currentEditedView error: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