Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Using drawRow:clipRect? Drawing over the row...

Using drawRow:clipRect? Drawing over the row...
Thread Tools
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Jan 19, 2005, 02:07 AM
 
Hi guys,

I would like to use drawRow: clipRect: in a table view subclass, and have got it working to a certain degree. Just for test purposes I have done this (found from some other code on the list):

- (void)drawRowint)row clipRectNSRect)frame
{
if ([self isRowSelected:row])
{
NSColor *bgColor = [NSColor blueColor];
if (bgColor != nil)
{
NSRect r = [self rectOfRow:row];
[bgColor set];
NSRectFill(NSIntersectionRect(r, frame));
}
}
else
[super drawRow:row clipRect:frame];
}

This makes the selected row blue, but as a side effect it seems, it draws the blue OVER my table view content, so all I can see is just the blue row and no text or anything in my data source.

Any ideas appreciated,
Oliver
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jan 19, 2005, 10:51 AM
 
You might try using the table view's delegate method:

- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex

and setting the background color of aCell, instead.

Edit: stupid smilies!
[Wevah setPostCount:[Wevah postCount] + 1];
     
Grizzled Veteran
Join Date: Jun 2002
Status: Offline
Reply With Quote
Jan 19, 2005, 04:36 PM
 
I ended up fixing this by using this private method:

- (id)_highlightColorForCellNSCell *)cell;

And returning nil, seemed to work fine.

Thanks,
Oliver
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jan 20, 2005, 11:29 AM
 
Cool; glad you got it working.
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:05 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2