• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem drawing outside of drawRect: in a custom table cell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Subject: Re: Problem drawing outside of drawRect: in a custom table cell
  • From: Graham Cox <email@hidden>
  • Date: Thu, 11 Dec 2008 09:57:04 +1100


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:
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>)

  • Prev by Date: Re: How to launch window of the application on clicking of dock icon?
  • Next by Date: large texts in NSTextView on 10.4
  • Previous by thread: Re: Problem drawing outside of drawRect: in a custom table cell
  • Next by thread: The thread that starts by NSTask didn't clear up
  • Index(es):
    • Date
    • Thread