Re: Updating a cell in NSTableView - it just will not draw!
Re: Updating a cell in NSTableView - it just will not draw!
- Subject: Re: Updating a cell in NSTableView - it just will not draw!
- From: Graham Cox <email@hidden>
- Date: Mon, 21 Apr 2008 15:40:37 +1000
Aha - I think you've hit the nail on the head. You say "remember" but
I don't think I realised this.
In this case updating the data model is not really what I want - for
one thing it's quite expensive (potentially) and for another it makes
more sense to set the data model on the mouse-up after tracking
completes. So it looks like your second suggestion is probably what I
need to do. So the question is: is there a way to trigger the reload
of just a single row? This isn't necessarily the selected row... if I
just mark for update the cell rect for the row/column is NSTableView
smart enough to only request the data for that row/column?
Anyway I will experiment further - thanks for the tip.
------
S.O.S.
On 21 Apr 2008, at 3:24 pm, Jens Alfke wrote:
On 20 Apr '08, at 9:33 PM, Graham Cox wrote:
The problem I'm having is that when the menu is used to update the
cell in the table view, I just cannot get the darn thing to redraw.
At all. (at least until after the menu tracking returns and it goes
away). I've tried:
Remember, a table view doesn't have a unique NSCell object per table
cell; instead the same cell object is used to draw every table cell
in a column. So changing the cell's value yourself isn't going to
affect what's shown in the table. The value stored in the cell when
it's drawn in the table is the result of the dataSource's
objectValueForTableColumn: method.
So it sounds like what's happening is that your fake-menu, during
mouse tracking, hasn't yet updated the data model that's acting as
the table's data source. If so, the table cell isn't going to change
its appearance. You either have to stuff a new value into the data
model during tracking, or play games with the data source's
objectValueForTableColumn: method to make it return the interim
value when the right row/column is requested.
—Jens
_______________________________________________
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