Re: Gradient NSOutlineView row - Text color of it's NSTextFieldCell
Re: Gradient NSOutlineView row - Text color of it's NSTextFieldCell
- Subject: Re: Gradient NSOutlineView row - Text color of it's NSTextFieldCell
- From: Oliver Quas <email@hidden>
- Date: Mon, 30 Jul 2007 10:26:55 +0200
hi Florian,
i prefer _not_ overwriting private methods (that's because they are
_private_ and you never know, when Apple will change them).
there's another way of doing what you want (in case i correctly
understand what you want to do). please have a look at the code below.
the first two methods remove the background highlighting from the
cell, as in some cases it is pretty boring, to have the table view
draw the selection and the cell drawing a highlighting (usually of
the same color the table view's selection color) on top of that
selection as well. in this case, we don't need the cell to draw a
highlighting background...
the last method actually sets the text color when the cell is being
drawn, so there's no delay or anything like that.
please note, that the table view (or any other control view) will
handle the highlighting of the cell automatically, so you don't have
to fiddle around with some custom code.
hope, this helps.
best regards,
oliver
- (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView
{
return nil;
}
- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView:
(NSView *)controlView
{
// make sure the cell doesn't draw any highlighting at all
[super highlight:NO withFrame:cellFrame inView:controlView];
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSButton *)controlView
{
// set the appropriate text color...
if ([self isHighlighted]) {
[self setTextColor:[NSColor whiteColor]];
} else {
[self setTextColor:[NSColor textColor]];
}
[self drawInteriorWithFrame:cellFrame inView:controlView];
}
_______________________________________________
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