i have nscollectionview bound nsarraycontroller. want drag , drop working, create delegate , implement methods
-(bool)collectionview:(nscollectionview *)collectionview candragitemsatindexes:(nsindexset *)indexes withevent:(nsevent*)event -(bool)collectionview:(nscollectionview *)collectionview acceptdrop:(id < nsdragginginfo >)dragginginfo index:(nsinteger)index dropoperation:(nscollectionviewdropoperation)dropoperation -(nsdragoperation)collectionview:(nscollectionview *)collectionview validatedrop:(id < nsdragginginfo >)dragginginfo proposedindex:(nsinteger *)proposeddropindex dropoperation:(nscollectionviewdropoperation *)proposeddropoperation -(nsarray *)collectionview:(nscollectionview *)collectionview namesofpromisedfilesdroppedatdestination:(nsurl *)dropurl fordraggeditemsatindexes:(nsindexset *)indexes
i'm returning yes 2 bool methods, nsdragoperationmove validatedrop: method, , empty array namesofpromisedfilesdroppedatdestination: method. have nslog statement first line in each method can see when called.
right now, method gets called candragitemsatindexes: (where return yes). see gets called, further dragging modifies selection. rest never called.
if make nscollectionview not support selections, not method gets called.
i'm sure i'm missing super obvious, can't figure out is. has gotten drag , drop working nscollectionviews , can shed light?
i think miss part write drag content pasteboard.
support drag , drop have perform following steps:
- determine if can drag in drag source
- if
yes
, write content pasteboard - validate & accept items in drop target
writing pasteboard should implemented in
- collectionview:writeitemsatindexes:topasteboard:
you have register dragged types - registerfordraggedtypes:
some sample code: http://developer.apple.com/library/mac/#samplecode/iconcollection/introduction/intro.html
Comments
Post a Comment