Drag and drop single cell in a table/matrix
Drag and drop single cell in a table/matrix
- Subject: Drag and drop single cell in a table/matrix
- From: Dan Waltin <email@hidden>
- Date: Thu, 28 Feb 2008 23:14:53 +0100
Hi all,
The short question is: how do I drag'n'drop single cells in an
NSTableView (or NSOutlineView). I.e. I don't want the entire row to be
dragged, just one cell.
Is there any example code on how to do this? Or is there anyone who
might push me in the right direction? Is
tableView:shouldTrackCell:forTableColumn:row: something I should learn
more about? Or is writeRowsWithIndexes what I want?
I googled myself dizzy but haven't found an answer. The NSMatrix class
looks promising, but I need different column widths as well as
headers. The NSTableView also looks promising, but dragging seems very
"row based".
A little more information about the situation: I have a model which
(simplified) looks like this: there is an Area entity and a Type
entity and finally an Item entity. The Area and Type entities have a
title property.
Each Item belongs to exactly one Area and one Type
Item <<----> Area
Item <<----> Type
There might or might not be an Item for a specific Area/Type
combination.
There is no (explicit) relation between Area and Type. I would like to
present this in a "matrix" (NSTableView, NSMatrix, or ???) with Area-s
going vertical and Type-s going horizontal. Like this (monospaced font
probably required...):
| Type1 | Type2 |
------+---------+--------+
Area1 | Item11 | |
------+---------+--------+
Area2 | | Item22 |
------+---------+--------+
Area3 | Item31 | Item32 |
------+---------+--------+
And now the tricky part, there might be a relation between two Item-s.
This relation is defined by the user and I would like to implement
this with drag and drop. Of course I could use a context menu, but
drag and drop feels much more "mac-like" and elegant.
So, for creating a relation between Item11 and, say, Item32, the user
drag and drops the *cell* Item11 on the cell Item32.
Thanks
/Dan
_______________________________________________
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