Revision: 29279 http://sourceforge.net/p/bibdesk/svn/29279 Author: hofman Date: 2025-07-15 09:28:35 +0000 (Tue, 15 Jul 2025) Log Message: ----------- hook to decide whether sheet can be dismissed, commits edits by default when NSEditor is implemented.
Modified Paths: -------------- trunk/bibdesk/BDSKCharacterConversion.m trunk/bibdesk/BDSKDocumentInfoWindowController.m trunk/bibdesk/BDSKFieldSheetController.m trunk/bibdesk/BDSKFilterController.m trunk/bibdesk/BDSKScriptGroupSheetController.m trunk/bibdesk/BDSKSearchGroupSheetController.m trunk/bibdesk/BDSKTextImportController.m trunk/bibdesk/BDSKURLGroupSheetController.m trunk/bibdesk/NSWindowController_BDSKExtensions.h trunk/bibdesk/NSWindowController_BDSKExtensions.m Modified: trunk/bibdesk/BDSKCharacterConversion.m =================================================================== --- trunk/bibdesk/BDSKCharacterConversion.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKCharacterConversion.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -167,22 +167,18 @@ #pragma mark Actions -- (IBAction)dismiss:(id)sender { +- (BOOL)shouldDismissSheetWithResult:(NSModalResponse)result { // commit edit before saving - if ([sender tag] == NSModalResponseCancel) { - [self discardEditing]; - } else if (NO == [self commitEditing]) { - NSBeep(); - return; - } + if ([super shouldDismissSheetWithResult:result] == NO) + return NO; - if ([sender tag] == NSModalResponseOK) { + if (result == NSModalResponseOK) { if (!validRoman || !validTex) { NSAlert *alert = [[NSAlert alloc] init]; [alert setMessageText:NSLocalizedString(@"Invalid Conversion", @"Message in alert dialog when entering invalid TeX conversion")]; [alert setInformativeText:NSLocalizedString(@"The last item you entered is invalid or a duplicate. Please first edit it.", @"Informative text in alert dialog")]; [alert beginSheetModalForWindow:[self window] completionHandler:NULL]; - return; + return NO; } NSError *error = nil; @@ -214,7 +210,7 @@ [tableView reloadData]; } - [super dismiss:sender]; + return YES; } - (IBAction)changeList:(id)sender { Modified: trunk/bibdesk/BDSKDocumentInfoWindowController.m =================================================================== --- trunk/bibdesk/BDSKDocumentInfoWindowController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKDocumentInfoWindowController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -109,17 +109,6 @@ #pragma mark Button actions -- (IBAction)dismiss:(id)sender{ - if ([sender tag] == NSModalResponseCancel) { - [self discardEditing]; - } else if (NO == [self commitEditing]) { - NSBeep(); - return; - } - - [super dismiss:sender]; -} - - (IBAction)addRemoveKey:(id)sender{ if ([sender selectedSegment] == 0) { // add Modified: trunk/bibdesk/BDSKFieldSheetController.m =================================================================== --- trunk/bibdesk/BDSKFieldSheetController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKFieldSheetController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -117,10 +117,8 @@ [super beginSheetModalForWindow:window completionHandler:handler]; } -- (IBAction)dismiss:(id)sender { - if ([sender tag] == NSModalResponseCancel || choosableFields == nil || ([objectController commitEditing] && [NSString isEmptyString:[self chosenField]] == NO)) { - [super dismiss:sender]; - } +- (BOOL)shouldDissmissSheetWithResult:(NSModalResponse)result { + return (result == NSModalResponseCancel || choosableFields == nil || ([objectController commitEditing] && [NSString isEmptyString:[self chosenField]] == NO)); } - (void)didDismissSheet { Modified: trunk/bibdesk/BDSKFilterController.m =================================================================== --- trunk/bibdesk/BDSKFilterController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKFilterController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -110,14 +110,6 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleScrollerStyleChanged:) name:NSPreferredScrollerStyleDidChangeNotification object:nil]; } -- (IBAction)dismiss:(id)sender { - if ([sender tag] == NSModalResponseOK && [self commitEditing] == NO) { - NSBeep(); - } else { - [super dismiss:sender]; - } -} - - (void)didDismissSheet { [conditionControllers setValue:nil forKey:@"filterController"]; } Modified: trunk/bibdesk/BDSKScriptGroupSheetController.m =================================================================== --- trunk/bibdesk/BDSKScriptGroupSheetController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKScriptGroupSheetController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -107,14 +107,6 @@ return isValid; } -- (IBAction)dismiss:(id)sender { - if ([sender tag] == NSModalResponseOK && [self commitEditing] == NO) { - NSBeep(); - } else { - [super dismiss:sender]; - } -} - - (void)didDismissSheet { [objectController setContent:nil]; } Modified: trunk/bibdesk/BDSKSearchGroupSheetController.m =================================================================== --- trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKSearchGroupSheetController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -153,17 +153,12 @@ #pragma mark Actions -- (IBAction)dismiss:(id)sender { - if ([sender tag] == NSModalResponseOK) { - if ([self commitEditing] == NO) { - NSBeep(); - return; - } - if ([self isEditable]) - [serverInfo savePasswordInKeychain]; - } - - [super dismiss:sender]; +- (BOOL)shouldDismissSheetWithResult:(NSModalResponse)result { + if ([super shouldDismissSheetWithResult:result] == NO) + return NO; + if (result == NSModalResponseOK && [self isEditable]) + [serverInfo savePasswordInKeychain]; + return YES; } - (IBAction)selectPredefinedServer:(id)sender; Modified: trunk/bibdesk/BDSKTextImportController.m =================================================================== --- trunk/bibdesk/BDSKTextImportController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKTextImportController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -252,7 +252,7 @@ [itemTableView setTypeSelectHelper:nil]; - [super dismiss:sender]; + [self dismiss:sender]; } - (IBAction)addItemAndCloseAction:(id)sender{ Modified: trunk/bibdesk/BDSKURLGroupSheetController.m =================================================================== --- trunk/bibdesk/BDSKURLGroupSheetController.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/BDSKURLGroupSheetController.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -82,14 +82,6 @@ return @"BDSKURLGroupSheet"; } -- (IBAction)dismiss:(id)sender { - if ([sender tag] == NSModalResponseOK && [self commitEditing] == NO) { - NSBeep(); - } else { - [super dismiss:sender]; - } -} - - (void)didDismissSheet { [objectController setContent:nil]; } Modified: trunk/bibdesk/NSWindowController_BDSKExtensions.h =================================================================== --- trunk/bibdesk/NSWindowController_BDSKExtensions.h 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/NSWindowController_BDSKExtensions.h 2025-07-15 09:28:35 UTC (rev 29279) @@ -53,6 +53,7 @@ - (IBAction)dismiss:(nullable id)sender; +- (BOOL)shouldDismissSheetWithResult:(NSModalResponse)result; - (void)didDismissSheet; @end Modified: trunk/bibdesk/NSWindowController_BDSKExtensions.m =================================================================== --- trunk/bibdesk/NSWindowController_BDSKExtensions.m 2025-07-14 16:00:07 UTC (rev 29278) +++ trunk/bibdesk/NSWindowController_BDSKExtensions.m 2025-07-15 09:28:35 UTC (rev 29279) @@ -101,9 +101,23 @@ }]; } +- (BOOL)shouldDismissSheetWithResult:(NSModalResponse)result { + if (result == NSModalResponseCancel) { + if ([self respondsToSelector:@selector(discardEditing)]) + [self discardEditing]; + } else if ([self respondsToSelector:@selector(commitEditing)]) { + return [self commitEditing]; + } + return YES; +} + - (void)didDismissSheet {} - (IBAction)dismiss:(id)sender { + if ([self shouldDismissSheetWithResult:[sender tag]] == NO) { + NSBeep(); + return; + } NSWindow *window = [[self window] sheetParent]; [window endSheet:[self window] returnCode:[sender tag]]; } 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