Revision: 27419
          http://sourceforge.net/p/bibdesk/svn/27419
Author:   hofman
Date:     2022-05-14 17:37:46 +0000 (Sat, 14 May 2022)
Log Message:
-----------
combine begin/end editing methods

Modified Paths:
--------------
    trunk/bibdesk/BDSKEditor.m

Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m  2022-05-14 13:55:03 UTC (rev 27418)
+++ trunk/bibdesk/BDSKEditor.m  2022-05-14 17:37:46 UTC (rev 27419)
@@ -331,20 +331,16 @@
     [super dealloc];
 }
 
-- (void)beginEditing {
-    if (editorFlags.isEditing == NO) {
-        [[self document] objectDidBeginEditing:(id)self];
-        editorFlags.isEditing = YES;
+- (void)setEditing:(BOOL)flag {
+    if (editorFlags.isEditing != flag) {
+        if (flag)
+            [[self document] objectDidBeginEditing:(id)self];
+        else
+            [[self document] objectDidEndEditing:(id)self];
+        editorFlags.isEditing = flag;
     }
 }
 
-- (void)endEditing {
-    if (editorFlags.isEditing) {
-        [[self document] objectDidEndEditing:(id)self];
-        editorFlags.isEditing = NO;
-    }
-}
-
 static inline BOOL validRanges(NSArray *ranges, NSUInteger max) {
     for (NSValue *range in ranges) {
         if (NSMaxRange([range rangeValue]) > max)
@@ -400,7 +396,7 @@
             }
         }
     }
-    [self endEditing];
+    [self setEditing:NO];
 }
 
 - (void)commitEditingWithDelegate:(id)delegate 
didCommitSelector:(SEL)didCommitSelector contextInfo:(void *)contextInfo
@@ -2124,7 +2120,7 @@
 }
 
 - (void)controlTextDidBeginEditing:(NSNotification *)note {
-    [self beginEditing];
+    [self setEditing:YES];
 }
 
 // send by the formatter when validation failed
@@ -2267,7 +2263,7 @@
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)notification{
-    [self endEditing];
+    [self setEditing:NO];
        
     if ([tableView rowForView:[notification object]] != -1)
         [tableCellFormatter setEditAsComplexString:NO];
@@ -2277,7 +2273,7 @@
     NSInteger row = [tableView rowForView:control];
     if (commandSelector == @selector(cancelOperation:)) {
         [control abortEditing];
-        [self endEditing];
+        [self setEditing:NO];
         if (row != -1)
             [tableCellFormatter setEditAsComplexString:NO];
         return YES;
@@ -2350,7 +2346,7 @@
     
     // save off the old value in case abortEditing gets called
     [self setPreviousValueForCurrentEditedNotesView:[currentEditedView 
string]];
-    [self beginEditing];
+    [self setEditing:YES];
 }
 
 // Clear all the undo actions when changing tab items, just in case; otherwise 
we
@@ -2375,7 +2371,7 @@
 
 // sent by the textViews
 - (void)textDidEndEditing:(NSNotification *)aNotification{
-    [self endEditing];
+    [self setEditing:NO];
     
     NSString *field = nil;
     if(currentEditedView == notesView)
@@ -2993,7 +2989,7 @@
         NO == [[self window] makeFirstResponder:[self window]])
         [self discardEditing];
     else
-        [self endEditing];
+        [self setEditing:NO];
     
     // see method for notes
     [self breakTextStorageConnections];
@@ -3031,7 +3027,7 @@
             NO == [[self window] makeFirstResponder:[self window]])
             [self discardEditing];
         else
-            [self endEditing];
+            [self setEditing:NO];
     }
     [super setDocument:document];
 }

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

Reply via email to