On 13 Nov 2009, at 17:02, Corbin Dunn wrote: > > On Nov 13, 2009, at 8:19 AM, jonat...@mugginsoft.com wrote: > >> >> On 13 Nov 2009, at 15:15, Corbin Dunn wrote: >> >>> >>> On Nov 13, 2009, at 6:35 AM, jonat...@mugginsoft.com wrote: >>> >>>> I have a subclassed NSTextFieldCell to create a cell that draws outside of >>>> it's frame. >>> >>> All the logic in tableview redraws things based on >>> -frameOfCellAtColumn:row:. Things will frequently not get redrawn if you >>> draw outside of those bounds. >>> >>> I recommend using a "full width" cell. See the AppKit release notes for 10.5 >> Unfortunately this won't work in this situation as my custom cell is only >> drawing over the last half of the table width. >> >> I looked -frameOfCellAtColumn:row: but overriding it seems impracticable. >> >> It seems very weird that the problem pops up following an undo (it is a >> coredata app though...). >> Surely the NSTableColumn + NSCell won't know about the undo? >> >> I use the same cell subclass in an NSOutlineView of the same data and it >> works fine. > > It works fine purely by chance! Plus, there are probably some cases where it > doesn't update properly (and you just haven't noticed yet). If the table > needs to redraw cell X at column Y, it will mark the area dirty via > -frameOfCellAtColumn:Y row:X. > >> Would this and the fact that NSOutlineView is an NSTableView subclass tend >> to indicate that I am screwing up somewhere? > > The error is having the cell draw outside of its given bounds. You need to > change that (or else do the invalidation yourself, which will be difficult to > get correct in all cases, unless you override frameOfCellAtColumn:row:. > Simply adding a -setNeedsDisplay:YES to redraw everything is bad for > performance). > Don't know what I was going on about before. There is nothing impracticable about overriding -frameOfCellAtColumn:row: In fact it's trivial. And, more to the point, it works.
/* frame of cell at column */ - (NSRect)frameOfCellAtColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex { NSRect rect = [super frameOfCellAtColumn:columnIndex row:rowIndex]; if (columnIndex == EXTENDED_COLUMN_INDEX) { NSCell *cell = [[[self tableColumns] objectAtIndex:columnIndex] dataCell]; if ([cell isKindOfClass:[MGSEntryTextCell class]] && [(MGSEntryTextCell *)cell extendCell]) { rect.size.width = [self frame].size.width - rect.origin.x; } } return rect; } Many thanks. I think that this would have eluded me without your input. Jonathan > --corbin > > > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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/archive%40mail-archive.com This email sent to arch...@mail-archive.com