Re: NSTableView selection
Re: NSTableView selection
- Subject: Re: NSTableView selection
- From: Elisabeth Freeman <email@hidden>
- Date: Tue, 11 Nov 2003 20:39:45 -0800
I got a solution to this problem, thanks! (Although I'm still curious
why the default mouse behavior on the two different view types is
different).
I did exactly as mmalcolm suggested, writing the rows to the pasteboard
and using the rows to get a reference to what is being dragged. The
reason I couldn't use what would normally be on the pasteboard (the
items) is that those items on the pasteboard are copies, not the
references to the objects.
Getting them from the rows information worked great.
On Nov 10, 2003, at 9:40 PM, mmalcolm crawford wrote:
>
Most of the dragging methods have an info argument of type
>
NSDraggingInfo. From that you can get the draggingSource. In this
>
case it should be the other table view. So, assuming yours is a
>
fairly standard document-based app, you should be able to send it a:
>
[[draggingSource window] delegate]
>
message to get the document object? From which you could presumably
>
get whatever information you want? If you want to, if you're using
>
Panther, you could put an NSIndexSet on the pasteboard to indicate
>
what the current selection is in the source?
>
>
In - (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows
>
toPasteboard:(NSPasteboard*)pboard, the information you put onto the
>
pasteboard should indicate what rows are being dragged (the
>
"selection"). So you might have something like:
>
>
- (BOOL)tableView:(NSTableView *)tv writeRows:(NSArray*)rows
>
toPasteboard:(NSPasteboard*)pboard
>
{
>
[pboard declareTypes:[NSArray arrayWithObject:DRAGGED_ROWS]
>
owner:self];
>
[pboard setPropertyList:rows forType:DRAGGED_ROWS];
>
return YES;
>
}
>
On Nov 10, 2003, at 9:40 PM, Elisabeth Freeman wrote:
>
>
> Hello,
>
> I'm having problems figuring out how to correctly implement drag and
>
> drop on a table view because of the way the table section works.
>
>
>
> I am using a selectedRowEnumerator to look at all objects that are
>
> being dragged - that is all selected objects. However, it is
>
> possible to drag an item in the table without selecting it because
>
> the mouse-down action does not actually select the row. As has been
>
> previously pointed out, perhaps this is correct behavior, but I find
>
> it odd because the default behavior of the OutlineView is to select
>
> on a mouse-down. So why is the selection behavior different for
>
> these two objects?
>
>
>
> In addition, it makes it very difficult to tell what is being
>
> dragged, because you can't used the selectedRowEnumerator to figure
>
> out what rows are selected because they aren't selected! (Well in
>
> the case where there's more than one, obviously you have to select
>
> the rows to drag multiple rows, but in the case of one row, you
>
> don't).
>
>
>
> So...
>
>
>
> 1) why is the behavior different for NSTableView and NSOutlineView?
>
> 2) is there a way to force a selection on a mouse down in NSTableView
>
> -or-
>
> 3) is there a way to tell what row is being dragged without actually
>
> selecting it?
>
>
>
> Thank you!!!!!
>
>
>
> Elisabeth
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.