Re: Highlight color of a NSTableView row
Re: Highlight color of a NSTableView row
- Subject: Re: Highlight color of a NSTableView row
- From: Ben Lachman <email@hidden>
- Date: Fri, 11 Apr 2008 00:21:30 -0400
I do something like this:
@implementation HilightingTextFieldCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
if( [self isHighlighted] ) {
NSColor *oldColor = [self textColor];
[self setTextColor:[NSColor alternateSelectedControlTextColor]];
[super drawWithFrame:cellFrame inView:controlView];
[self setTextColor:oldColor];
} else {
[super drawWithFrame:cellFrame inView:controlView];
}
}
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
return nil;
}
@end
HTH,
->Ben
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
email@hidden
740.590.0009
On Apr 10, 2008, at 8:47 PM, Eric Gorr wrote:
On Apr 10, 2008, at 8:30 PM, Corbin Dunn wrote:
Playing with this a bit more, it appears that I need to also do:
- (id)_highlightColorForCell:(NSCell *)cell
{
// we need to override this to return nil
// or we'll see the default selection rectangle when the app is
running
// in any OS before leopard
// you can also return a color if you simply want to change the
table's default selection color
return nil;
}
Or it will ignore my highlight drawing entirely. It appears this
is an undocumented API or, at least, I cannot locate it in the
documentation.
If a method starts with an underscore, don't even bother looking
it up in the documentation :) -- not only is it undocumented, but
it is unsupported and might change in the future.
The proper thing to do:
1. Subclass NSCell, NSTextFieldCell, or whatever other cell you want.
2. Override:
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:
(NSView *)controlView
and return nil.
How would I go about subclassing NSTextFieldCell & NSImageCell and
then using these cell with my NSTableView?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden