Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem drawing outside of drawRect: in a custom table cell




On 11 Dec 2008, at 3:46 am, Corbin Dunn wrote:

There are various reasons why this happens; for one, the focus ring may bleed into the rect that was invalidated. But, as you have noticed, you should not rely on invalidating just a small portion and hoping only that portion should redraw.

I think it is still correct to invalidate your cell's rect, and have the table redraw (potentially redrawing everything).


OK, at least that confirms my observations - I'm not going mad after all! (Or I might be, but not because of this...)

I think you should try another approach. Go back to invalidating the rect of the cell that you want to redraw. Essentially, you want one cell to maintain specific state while you are doing something else.

Exactly.

There is one easy approach to do this, which is to maintain a copy of the cell while you are showing your special menu, and use that cell to draw *just* that one particular row/column.

D'oh! Of course. A copy... obvious, now you point it out.

General steps:
1. Save off the row/column
2. Copy the cell at that row/column when showing your menu
3. Always return that copied cell from the delegate method:
- (NSCell *)tableView:(NSTableView *)tableView dataCellForTableColumn:(NSTableColumn *)tableColumn row: (NSInteger)row AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
else, return [tableColumn dataCell].
4. Don't update the properties for that row/column in -willdisplaycell
5. Update the colors of that copied cell when your menu changes state
6. Drop the copied cell when your menu goes away.


Another approach would be something similar to this great example:

	<http://developer.apple.com/samplecode/PhotoSearch/>

.corbin


Great, I'll give this a shot. Actually I woke up this morning thinking that I'd need to do something along these lines (isolate the cell being tracked), so sleeping on it really works - I definitely should avoid these 16 hour straight coding sessions... I'll also check out the suggested sample.

Thanks!

--Graham


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Another NSOutlineView question (From: Graham Cox <email@hidden>)
 >Re: Another NSOutlineView question (From: Volker in Lists <email@hidden>)
 >Re: Another NSOutlineView question (From: Corbin Dunn <email@hidden>)
 >Re: Another NSOutlineView question (From: Graham Cox <email@hidden>)
 >Re: Another NSOutlineView question (From: Corbin Dunn <email@hidden>)
 >Re: Another NSOutlineView question (From: Graham Cox <email@hidden>)
 >Re: Another NSOutlineView question (From: Graham Cox <email@hidden>)
 >Problem drawing outside of drawRect: in a custom table cell (From: Graham Cox <email@hidden>)
 >Re: Problem drawing outside of drawRect: in a custom table cell (From: Corbin Dunn <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.