Revision: 26215 http://sourceforge.net/p/bibdesk/svn/26215 Author: hofman Date: 2021-06-12 22:16:53 +0000 (Sat, 12 Jun 2021) Log Message: ----------- Abort actions when ending edits fails
Modified Paths: -------------- trunk/bibdesk/BDSKCharacterConversion.h trunk/bibdesk/BDSKCharacterConversion.m Modified: trunk/bibdesk/BDSKCharacterConversion.h =================================================================== --- trunk/bibdesk/BDSKCharacterConversion.h 2021-06-12 18:28:41 UTC (rev 26214) +++ trunk/bibdesk/BDSKCharacterConversion.h 2021-06-12 22:16:53 UTC (rev 26215) @@ -82,7 +82,7 @@ @property (nonatomic, copy) NSDictionary *twoWayDict; - (void)updateButtons; -- (void)finalizeChangesIgnoringEdit:(BOOL)flag; +- (BOOL)finalizeChangesIgnoringEdit:(BOOL)flag; @end Modified: trunk/bibdesk/BDSKCharacterConversion.m =================================================================== --- trunk/bibdesk/BDSKCharacterConversion.m 2021-06-12 18:28:41 UTC (rev 26214) +++ trunk/bibdesk/BDSKCharacterConversion.m 2021-06-12 22:16:53 UTC (rev 26215) @@ -181,7 +181,11 @@ #pragma mark Actions - (IBAction)dismiss:(id)sender { - [self finalizeChangesIgnoringEdit:[sender tag] == NSCancelButton]; // commit edit before saving + // commit edit before saving + if (NO == [self finalizeChangesIgnoringEdit:[sender tag] == NSCancelButton]) { + NSBeep(); + return; + } if ([sender tag] == NSOKButton) { if (!validRoman || !validTex) { @@ -227,14 +231,19 @@ } - (IBAction)changeList:(id)sender { - [self finalizeChangesIgnoringEdit:NO]; // commit edit before switching - [self setListType:[[sender selectedItem] tag]]; + // commit edit before switching + if ([self finalizeChangesIgnoringEdit:NO]) + [self setListType:[[sender selectedItem] tag]]; + else + NSBeep(); } - (IBAction)addRemove:(id)sender { if ([sender selectedSegment] == 0) { // add - [self finalizeChangesIgnoringEdit:NO]; // make sure we are not editing + // make sure we are not editing + if (NO == [self finalizeChangesIgnoringEdit:NO]) + return; NSString *newRoman = [NSString stringWithFormat:@"%C", (unichar)0x00E4]; NSString *newTex = @"{\\\"a}"; @@ -255,7 +264,9 @@ } else { // remove - [self finalizeChangesIgnoringEdit:YES]; // make sure we are not editing + // make sure we are not editing + if (NO == [self finalizeChangesIgnoringEdit:YES]) + return; NSInteger row = [tableView selectedRow]; if (row == -1) return; @@ -287,11 +298,11 @@ [addRemoveButton setEnabled:[tableView selectedRow] != -1 forSegment:1]; } -- (void)finalizeChangesIgnoringEdit:(BOOL)flag { +- (BOOL)finalizeChangesIgnoringEdit:(BOOL)flag { if (flag) - [tableView abortEditing]; + return [tableView abortEditing]; else - [[self window] makeFirstResponder:nil]; + return [[self window] makeFirstResponder:nil]; } #pragma mark NSTableview Datasource 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