Recalculating NSTableView row sizes during a live column resize
Recalculating NSTableView row sizes during a live column resize
- Subject: Recalculating NSTableView row sizes during a live column resize
- From: Keith Blount <email@hidden>
- Date: Thu, 25 Jun 2009 11:10:05 -0700 (PDT)
Hello,
I have a table view that has variable row heights based on the text in one of the columns. These row heights get recalculated at various times, and for the most part, all is good. Right now I'm trying to refine things a little, though, and one of the things that has always bugged me slightly about the way my table view currently works is the way it handles column resizing. The first problem is that NSTableViewColumnDidResizeNotification only ever gets sent after columns have *finished* resizing. What this means is that when the user resizes a column, the row heights don't get updated until after the resize is finished and the user releases the mouse. So the user resizes a column, lets go of the mouse button, and then the rows snap to their new heights. I would prefer the rows to resize "live" as the column is resized.
After digging around through these lists and Googling a lot (you know you're hitting a brick wall when you Google something and some of the most relevant results are your own questions from years ago :) ), I managed to get live resize notifications by subclassing NSTableColumn and telling my data source to recalculate the row heights in -setWidth: This enables me to call the row resizing code during a column resize so that the rows resize live as I had hoped...
...Except. Only the columns that are getting resized (the column the user is dragging and the last auto-sized column in this case) get drawn correctly with the new heights. All of the columns in-between - the columns whose widths *aren't* changing - refuse to redraw no matter what I try (I've tried forcing display and reloading the data from numerous places), and instead draw using the old row heights until column resizing ends and they snap to where they should be. My wild guess (well, not exactly - I'm sure I saw something on Google about this earlier but now cannot find it) is that during live column resizing, either the table header view or the table view itself cache an image of the columns that aren't being resized as they are at the beginning of the drag, and show that cached image rather than drawing the columns live using their NSCells. At least, that's the only reason I can think of for these columns not changing their row heights when the ones
being resized around them do.
Has anyone come across this problem or found a solution? Is there anyway of overriding that custom image, if that is indeed what it is?
Many thanks in advance and all the best,
Keith
_______________________________________________
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