Re: NSOutlineView Row Selection Color
Re: NSOutlineView Row Selection Color
- Subject: Re: NSOutlineView Row Selection Color
- From: haym37 <email@hidden>
- Date: Sun, 5 Feb 2006 10:54:27 -0500
Thanks for all your help! However, it is still not correctly
working. It is getting inside the _highlightColorForCell method
after I changed the Custom Class of the NSOutlineView to
LeftMenuController, although now, the text won't appear. If I click
on a row, nothing happens (however, if I change
_highlightColorForCell to return [NSColor redColor], when I click the
row it turns red, although there is still no text). It also goes
inside the highlightSelectionInClipRect, although nothing occurs
since, even if you click a row, the selectedRow is always -1 (it is,
however, receiving the outlineViewSelectionDidChange notification,
although [outlineView selectedRow] always returns -1). Any help
would be greatly appreciated. Thanks!
On Feb 5, 2006, at 6:22 AM, Keith Wilson wrote:
The following works if you simply want to override the default
(blue) highlight for the selected row with grey
-(id)_highlightColorForCell:(NSCell *)cell
{
return [NSColor colorWithCalibratedWhite:0.9f alpha:1.0f];
}
Keith
On 05/02/2006, at 7:59 PM, Guillaume Gandreau wrote:
Hi,
You have to teel IB that your outlineview is of type
LeftMenuController.h.
In Information panel, go to Custom class and choose your classe.
If your class doesn't appear, drag the header from XCode to IB.
Hope this help !
LeChatNoir
On 5 févr. 06, at 06:24, haym37 wrote:
After reading much about how to customize the color of the
selected row in an NSOutlineView, I am still unable to get it to
work. Here's what I have:
- LeftMenuController.h which is a subclass of NSOutlineView
- LeftMenuController.m which contains the following code:
- (id)_highlightColorForCell:(NSCell *)cell
{
NSLog(@"here");
return nil;
}
- (void)highlightSelectionInClipRect:(NSRect)clipRect
{
NSLog(@"here");
if (selectedRow != -1)
{
[outlineView lockFocus];
NSImage *gradientHighlight;
if(([[outlineView window] firstResponder] == outlineView) &&
[[outlineView window] isMainWindow] && [[outlineView window]
isKeyWindow])
{
gradientHighlight = [NSImage
imageNamed:@"LeftMenuRowHighlightFocused.png"];
}
else
{
gradientHighlight = [NSImage
imageNamed:@"LeftMenuRowHighlightUnFocus.png"];
}
[gradientHighlight setFlipped:NO];
[gradientHighlight setScalesWhenResized:YES];
NSRect drawingRect = [outlineView rectOfRow:selectedRow];
NSRect imageRect;
imageRect.origin = NSZeroPoint;
imageRect.size = [gradientHighlight size];
if(drawingRect.size.width != 0 && drawingRect.size.height != 0)
{
[gradientHighlight drawInRect:drawingRect fromRect:imageRect
operation:NSCompositeSourceOver fraction:1.0];
}
[outlineView unlockFocus];
}
}
In Interface Builder, I have LeftMenuController as the dataSource
and delegate of the NSOutlineView.
Still, when selecting a row in the NSOutlineView, rather than
displaying the background as the LeftMenuRowHighlightFocused.png
gradient, it still displays it as the standard dark blue.
Is there another thing that I should be doing to have it work?
Thanks!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40bigpond.net.au
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden