Re: NSTableView and rows of different "type"
Re: NSTableView and rows of different "type"
- Subject: Re: NSTableView and rows of different "type"
- From: "Michael Ash" <email@hidden>
- Date: Sun, 6 Jul 2008 11:31:04 -0400
On Sat, Jul 5, 2008 at 12:45 PM, Erik Elmgren <email@hidden> wrote:
> I think I understand how to solve the display part by using
> tableView:dataCellForTableColumn:row: and supplying a full-width cell
> (custom subclass), and then painting the fields inside by drawing other
> cells. But how do I solve that some of these cells need to be editable by
> the user?
The same way you handle drawing. Implement all of the NSCell event
methods, use the event's position to figure out which cell was hit,
and then pass the message to it. For example, if you have several
NSTextFieldCells, you'll keep track of their locations internally (or
calculate it each time you need it), see which one intersects the
point in question, then tell it that it was clicked. The
NSTextFieldCell will then take care of all the editing stuff for you.
> Alternatively, is there any way to reposition the cells
> horizontally (and change their width) for a specific row?
There is not, each NSTableColums is in a fixed location for the entire
extent of the table.
You might consider using an NSCollectionView for this instead. It
would allow you to have a custom NSView (rather than a custom NSCell)
for each row which could then have subviews positioned as you wished.
The downside is that, because it creates one view for every object in
the collection view, it has a lot of overhead if you have a large
number of objects to display.
Mike
_______________________________________________
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