Skip navigation.
 
mlDrawing only when NSOutlineView active?
FROM : Nicholas Riley
DATE : Sun Mar 02 14:39:38 2008

I'm attempting to draw a custom NSOutlineView row background only for 
selected rows of an active outline view; otherwise, the default 
drawing style is fine.  I started with the following:

- (void)highlightSelectionInClipRect:(NSRect)clipRect;
{
    // the outline view is in a sheet, so the main window is always 
the window to which it's attached
    if ([[self window] firstResponder] != self || ![[self window] 
isKeyWindow]) {
   [super highlightSelectionInClipRect: clipRect];
   return;
    }
    // fancy drawing here

This works fine except in two cases, when the test is inadequate and 
NSOutlineView draws an ordinary active row.

1. When another window, such as the Character Palette, or a status 
item gets keyboard focus.  To work around this, I can change the 
second check to:

   [NSApp keyWindow] != [self window]

    which surprisingly returns a different result than ![[self window] 
isKeyWindow].

2. When a menu-window (e.g., the help menu's NSCarbonMenuWindow) 
becomes key.  In this case, the key window changes by either measure.

Is there a more effective way to discover whether I should draw the 
row background as active or not?

--
Nicholas Riley <<email_removed>> | <http://www.uiuc.edu/ph/www/njriley>

Related mailsAuthorDate
No related mails found.