Re: bindings resize rowHeight problem in NSTableView
Re: bindings resize rowHeight problem in NSTableView
- Subject: Re: bindings resize rowHeight problem in NSTableView
- From: Greg Herlihy <email@hidden>
- Date: Fri, 10 Mar 2006 13:59:44 -0800
- Thread-topic: bindings resize rowHeight problem in NSTableView
The problem that you have encountered (which took me forever to figure out)
is that whenever the height of any row in a table changes, it is necessary
to inform the table that the height of that row has changed. Note further
that simply resorting a table can also "change" the height of a row, because
a "row" (at least as far as row heights are concerned) is defined by its
cardinality: (first row, second row, etc) and not by any associated content.
In my case, resorting the table led to the display and selection problems
that you have described. And since there is no practical way to tell which
row heights have in fact changed after resorting a table, my program simply
reported that the height of every row in the table changed after a resort.
And in order to execute the code to do so, the table made itself its own
delegate so it would be informed whenever its sort order may have changed.
In short, here is the routine to fix the problem as my program implemented
it:
-(void)tableView:(NSTableView*)tableView
didClickTableColumn:(NSTableColumn *)tableColumn
{
[self noteHeightOfRowsWithIndexesChanged:[NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [self numberOfRows])]];
[self tile];
[self setNeedsDisplay:YES];
}
In my limited testing of this fix, the problem does seem to be resolved - at
least in the case of resorting the table. It should be quite straightforward
to adopt this code for any other occasions when the row heights of the table
change.
Greg
On 3/10/06 12:58 PM, "Michael Link" <email@hidden> wrote:
> I have the rowHeight binding of an NSTableView bound to a BOOL that
> has a value transformer that returns 16 or 32. The table view also
> responds to - tableView:heightOfRow: and some row heights are
> different. (Think source list with the separators having smaller
> heights than the icons, and the icons are adjustable to be small or
> large. The table view also is set to automatically hide scrollers and
> automatically size last column to fit. There is no horizontal scroller.
>
> When I run my application and the source list icons are set to large
> (the document view over runs the clip view height so there is a
> vertical scrollbar) and I select the tableview to display small
> icons, the view switches to small icon view and has a drawing glitch
> at the very top (below the headerview), it draws one of my separator
> cells right below the headerview. Also data is small enough to fit
> within the tableview so the document view should shrink to fit within
> the clip view but it doesn't, thus the vertical scrollbar is still
> present. Subclassing in drawRect: and calling [self sizeToFit]
> doesn't seem to help.
>
> When I run my application and the source list icons are set to small
> initially and I select an option to have large icons displayed the
> tableview draws the cells but it doesn't seem to recalculate the
> documentview size (so even though the document size should be larger
> than the clip view it doesn't recognize this and doesn't draw a
> vertical scrollbar, I subclassed NSScrollView and noticed that the
> document view height in fact does not seem to get updated). The
> cursor rects don't seem to get updated for the cells that are drawn
> below where the previous small sized cells were drawn either (can not
> click the bottom 2 cells in the view, although the cells that are
> clickable do correspond to the correct selections).
>
> Hopefully some screen captures can help explain this too.
> http://julia.fractal.net/images/smalltolarge.jpg
>
> I've tried subclassing - [tile] in NSTableView and setting a new
> frame, which works except the cursor rects still do not get updated.
> I tried calling resetCursorRects but that didn't help either. I also
> noticed that when going from small to large icons that I can scroll
> to the bottom but the part of the cell that wasn't drawn in the
> redraw won't be drawn unless I click one of the cells.
>
> If anyone has any suggestions that would be much appreciated.
>
> --
> Michael
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden