Lefora Free Forum
login join
Loading
690 views

Higlight selection in NSOutlineView

Page 1
1–2
rookie - member
2 posts

Hi everybody,

I want to highlight selected rows with a tranparent image instead of colors.

Here's the code:

- (void)highlightSelectionInClipRect:(NSRect)theClipRect
{
    NSRange            aVisibleRowIndexes = [self rowsInRect:theClipRect];
    NSIndexSet *    aSelectedRowIndexes = [self selectedRowIndexes];
    int                aRow = aVisibleRowIndexes.location;
    int                anEndRow = aRow + aVisibleRowIndexes.length;
   
    for (aRow; aRow < anEndRow; aRow++)
    {
        if([aSelectedRowIndexes containsIndex:aRow])
        {
            NSRect aRowRect = NSInsetRect([self rectOfRow:aRow], 2, 1);
                   
            NSImage *    anIcon = [NSImage imageNamed:@"HighligthSelection"];
           
            [anIcon setFlipped:YES];
            [anIcon setSize:aRowRect.size];
           
            [anIcon drawAtPoint:aRowRect.origin fromRect:aRowRect operation:NSCompositeSourceOver fraction:1.0];
           
        }
    }
}

It does work for the first row of my NSOutlineView, but if I selected another one the image doesn't appear ...

Any idea ?

rookie - member
2 posts

And the answer is ....

[anIcon drawInRect:aRowRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];

instead of:

[anIcon drawAtPoint:aRowRect.origin fromRect:aRowRect operation:NSCompositeSourceOver fraction:1.0];

Page 1
1–2

Locked Topic


You must be a member to post in this forum

Join Now!