Revision: 24257 http://sourceforge.net/p/bibdesk/svn/24257 Author: hofman Date: 2019-09-29 21:00:30 +0000 (Sun, 29 Sep 2019) Log Message: ----------- ignore color changes when changing color from color label well
Modified Paths: -------------- trunk/bibdesk/BDSKColorLabelWell.h trunk/bibdesk/BDSKColorLabelWell.m trunk/bibdesk/BibDocument_Actions.m Modified: trunk/bibdesk/BDSKColorLabelWell.h =================================================================== --- trunk/bibdesk/BDSKColorLabelWell.h 2019-09-29 16:38:07 UTC (rev 24256) +++ trunk/bibdesk/BDSKColorLabelWell.h 2019-09-29 21:00:30 UTC (rev 24257) @@ -48,6 +48,9 @@ NSArray *trackingAreas; } ++ (BOOL)updatingColorPanel; ++ (void)setUpdatingColorPanel:(BOOL)flag; + @property (nonatomic) CGFloat margin; @property (nonatomic, copy) NSString *title; Modified: trunk/bibdesk/BDSKColorLabelWell.m =================================================================== --- trunk/bibdesk/BDSKColorLabelWell.m 2019-09-29 16:38:07 UTC (rev 24256) +++ trunk/bibdesk/BDSKColorLabelWell.m 2019-09-29 21:00:30 UTC (rev 24257) @@ -58,6 +58,16 @@ @dynamic margin, title, showLabel; +static BOOL updatingColorPanel = NO; + ++ (BOOL)updatingColorPanel { + return updatingColorPanel; +} + ++ (void)setUpdatingColorPanel:(BOOL)flag { + updatingColorPanel = flag; +} + - (void)makeMatrix { matrix = [[NSMatrix alloc] initWithFrame:NSMakeRect(0.0, 2.0, 178.0, 22.0)]; BDSKColorLabelCell *cell = [[[BDSKColorLabelCell alloc] initTextCell:@""] autorelease]; @@ -263,6 +273,14 @@ } } +- (BOOL)becomeFirstResponder { + if ([super becomeFirstResponder]) { + [[self window] makeFirstResponder:matrix]; + return YES; + } + return NO; +} + - (void)mouseDown:(NSEvent *)event {} - (void)changeColor:(id)sender {} @@ -302,7 +320,9 @@ } else if ([self isActive]) { [self deactivate]; } else { + [BDSKColorLabelWell setUpdatingColorPanel:YES]; [self activate:YES]; + [BDSKColorLabelWell setUpdatingColorPanel:NO]; if ([self action]) { suppressColor = YES; [NSApp sendAction:[self action] to:[self target] from:self]; Modified: trunk/bibdesk/BibDocument_Actions.m =================================================================== --- trunk/bibdesk/BibDocument_Actions.m 2019-09-29 16:38:07 UTC (rev 24256) +++ trunk/bibdesk/BibDocument_Actions.m 2019-09-29 21:00:30 UTC (rev 24257) @@ -94,13 +94,12 @@ #import "BDSKURLSheetController.h" #import "BDSKLinkedFile.h" #import "BDSKSplitView.h" +#import "BDSKColorLabelWell.h" #define BDSKLyXPipePathKey @"BDSKLyXPipePath" @implementation BibDocument (Actions) -static BOOL changingColors = NO; - #pragma mark - #pragma mark Publication actions @@ -421,9 +420,9 @@ } else if([colID isEqualToString:BDSKColorString] || [colID isEqualToString:BDSKColorLabelString]) { NSColor *color = [pub color]; if (color) { - changingColors = YES; + [BDSKColorLabelWell setUpdatingColorPanel:YES]; [[NSColorPanel sharedColorPanel] setColor:color]; - changingColors = NO; + [BDSKColorLabelWell setUpdatingColorPanel:NO]; } [[NSColorPanel sharedColorPanel] makeKeyAndOrderFront:nil]; } else if([colID isCitationField]) { @@ -641,10 +640,10 @@ } - (void)changeColor:(id)sender { - if ([self hasGroupTypeSelected:BDSKExternalGroupType] == NO && [self isDisplayingFileContentSearch] == NO && [[self selectedPublications] count] && changingColors == NO) { - changingColors = YES; + if ([self hasGroupTypeSelected:BDSKExternalGroupType] == NO && [self isDisplayingFileContentSearch] == NO && [[self selectedPublications] count] && [BDSKColorLabelWell updatingColorPanel] == NO) { + [BDSKColorLabelWell setUpdatingColorPanel:YES]; [[self selectedPublications] setValue:[sender color] forKey:@"color"]; - changingColors = NO; + [BDSKColorLabelWell setUpdatingColorPanel:NO]; [[self undoManager] setActionName:NSLocalizedString(@"Change Color", @"Undo action name")]; } } @@ -654,10 +653,10 @@ NSColor *color = [sender color]; if (color == nil) { [self selectPublications:[self clickedOrSelectedPublications]]; - } else if ([[self clickedOrSelectedPublications] count] > 0 && changingColors == NO) { - changingColors = YES; + } else if ([[self clickedOrSelectedPublications] count] > 0 && [BDSKColorLabelWell updatingColorPanel] == NO) { + [BDSKColorLabelWell setUpdatingColorPanel:YES]; [[self clickedOrSelectedPublications] setValue:[sender color] forKey:@"color"]; - changingColors = NO; + [BDSKColorLabelWell setUpdatingColorPanel:NO]; } } } 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