Custom drag image with NSTableView as drag source -
is necessary subclass nstableview or nstablecellview create custom drag image when tableview drag source?
if not, magic method missing this? cannot seem find solid.
nstablecellview subclasses have can (slightly mysteriously) override:
@property(retain, readonly) nsarray *draggingimagecomponents
(array of nsdraggingimagecomponent instances composited (who knows in fashion composited...))
nstableview has
- (nsimage *)dragimageforrowswithindexes:(nsindexset *)dragrows tablecolumns:(nsarray *)tablecolumns event:(nsevent *)dragevent offset:(nspointpointer)dragimageoffset
but these indeed subclassing options seems.
anybody know technique here? (10.8+ target )
it looks if nstableviewcell
@property(retain, readonly) nsarray *draggingimagecomponents
does not called automatically must explicitly referenced view based table views. -draggingimagecomponents
can overridden supply components used composite drag image.
- (void)tableview:(nstableview *)tableview draggingsession:(nsdraggingsession *)session willbeginatpoint:(nspoint)screenpoint forrowindexes:(nsindexset *)rowindexes { // configure drag image // dragging 1 item - changes required handle multiple drag items bppopupbuttontablecellview *cellview = [self.columnstableview viewatcolumn:0 row:rowindexes.firstindex makeifnecessary:no]; if (cellview) { [session enumeratedraggingitemswithoptions:nsdraggingitemenumerationconcurrent forview:tableview classes:[nsarray arraywithobject:[nspasteboarditem class]] searchoptions:nil usingblock:^(nsdraggingitem *draggingitem, nsinteger idx, bool *stop) { // can set drag image directly //[draggingitem setdraggingframe:nsmakerect(0, 0, mywidth, myheight) contents:myfunkydragimage]; // tableview grab entire table cell view bounds image default. // can override nstablecellview -draggingimagecomponents // defaults including image , text fields draggingitem.imagecomponentsprovider = ^nsarray*(void) { return cellview.draggingimagecomponents;}; }]; } }
Comments
Post a Comment