NSTableView dragging source image
NSTableView dragging source image
- Subject: NSTableView dragging source image
- From: Dragan Milić via Cocoa-dev <email@hidden>
- Date: Tue, 21 Mar 2023 11:49:38 +0100
Hi all,
I have a simple problem, but I’m not able to solve it in an easy way, so I
suspect I’m doing something wrong.
I have a simple view-based NSTableView, which is a dragging source. The data
being dragged are provided to the pasteboard using the standard data source
method - [NSObject tableView:writeRowsWithIndexes:toPasteboard:]. When rows of
the table view are dragged, AppKit automatically creates a dragging image
consisting of the visual copy for all dragged rows and all columns of the table
view. If I want only particular columns, I can override -[NSTableView
dragImageForRowsWithIndexes:tableColumns:event:offset:] and include only the
columns I want in the dragged image.
Since [NSObject tableView:writeRowsWithIndexes:toPasteboard:] is rendered
deprecated as of macOS 11, I want to use the alternative (which also supports
multiple item dragging) -[NSObject tableView:pasteboardWriterForRow:]. However,
when I use this method, AppKit creates a dragging image consisting of the
visual copy for all dragged rows, BUT ONLY the column where the drag started.
Overriding -[NSTableView
dragImageForRowsWithIndexes:tableColumns:event:offset:] has no effect, as in
this case that method isn’t being called at all.
So the question is, how do I influence the dragging image creation in the
latter case? I haven’t found in docs anything related to that (except for the
method mentioned above, but not being called in this case). Implementing data
source method -[NSObject tableView:updateDraggingItemsForDrag:] doesn’t help,
as it’s really intended to change the dragging image after the dragging has
started and at the time it’s called for the first time, the AppKit created
image is already there and visible.
Thanks a lot for any solution, hint or a suggestion.
-- Dragan
_______________________________________________
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