Revision: 26192 http://sourceforge.net/p/bibdesk/svn/26192 Author: hofman Date: 2021-06-10 09:20:18 +0000 (Thu, 10 Jun 2021) Log Message: ----------- Separate method to get enclosing clipviews of editor
Modified Paths: -------------- trunk/bibdesk/BDSKComplexStringEditor.m Modified: trunk/bibdesk/BDSKComplexStringEditor.m =================================================================== --- trunk/bibdesk/BDSKComplexStringEditor.m 2021-06-10 09:14:54 UTC (rev 26191) +++ trunk/bibdesk/BDSKComplexStringEditor.m 2021-06-10 09:20:18 UTC (rev 26192) @@ -44,6 +44,8 @@ @interface BDSKComplexStringEditor (Private) +- (BOOL)getEnclosingView:(NSView **)view scrollingView:(NSView **)contentView; + - (void)editorFrameDidChange:(NSNotification *)notification; - (void)editorWindowDidChangeKey:(NSNotification *)notification; - (void)editorWindowWillClose:(NSNotification *)notification; @@ -93,14 +95,10 @@ [backgroundView setShowFocusRing:[editor isEditable]]; // the editor may be wrapped in a clipview, and perhaps a scrollview - NSView *view = [editor superview]; - NSView *contentView = [[view enclosingScrollView] contentView]; - if ([view isKindOfClass:[NSClipView class]] == NO) { - view = editor; - } else if (contentView == view) { - view = [view enclosingScrollView]; - contentView = [[view enclosingScrollView] contentView]; - } + NSView *view = nil; + NSView *contentView = nil; + if (NO == [self getEnclosingView:&view scrollingView:&contentView]) + return; // track changes in the text, the frame and the window's key status of the editor NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; @@ -182,17 +180,21 @@ [expandedValueTextField setFormatter:[[[BDSKComplexStringFormatter alloc] init] autorelease]]; } -// @@ Dark mode - -- (void)displayValue:(NSString *)stringValue isError:(BOOL)isError { - [expandedValueTextField setObjectValue:stringValue]; - if (isError) { - [expandedValueTextField setTextColor:[NSColor systemRedColor]]; - [expandedValueTextField setToolTip:[NSString stringWithFormat:NSLocalizedString(@"Invalid BibTeX string: %@. This change will not be recorded.", @"Tool tip message"), stringValue]]; - } else { - [expandedValueTextField setTextColor:[NSColor controlTextColor]]; - [expandedValueTextField setToolTip:NSLocalizedString(@"This field contains macros and is being edited as it would appear in a BibTeX file. This is the expanded value.", @"Tool tip message")]; +- (BOOL)getEnclosingView:(NSView **)view scrollingView:(NSView **)contentView { + *view = [editor superview]; + *contentView = [[*view enclosingScrollView] contentView]; + if (view == nil) { + // editor is not editing, should never happen + [self remove]; + } else if ([*view isKindOfClass:[NSClipView class]] == NO) { + // editor not wrapped in a clipview + *view = editor; + } else if (*contentView == *view) { + // editor wrapped in a scrollview + *view = [*view enclosingScrollView]; + *contentView = [[*view enclosingScrollView] contentView]; } + return YES; } #pragma mark Frame change and keywindow notification handlers @@ -199,19 +201,10 @@ - (void)editorFrameDidChange:(NSNotification *)notification { // the editor may be wrapped in a clipview and perhaps a scrollview - NSView *view = [editor superview]; - NSView *contentView = [[view enclosingScrollView] contentView]; - if ([view isKindOfClass:[NSClipView class]] == NO) { - // should not happen - if (view == nil) { - [self remove]; - return; - } - view = editor; - } else if (contentView == view) { - view = [view enclosingScrollView]; - contentView = [[view enclosingScrollView] contentView]; - } + NSView *view = nil; + NSView *contentView = nil; + if (NO == [self getEnclosingView:&view scrollingView:&contentView]) + return; NSRectEdge lowerEdge = [view isFlipped] ? NSMaxYEdge : NSMinYEdge; NSRect lowerEdgeRect = NSInsetRect([view bounds], -2.0, -2.0); 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