osx - On Mac, Drag file to my NSTableVIew? -
i able drag (any) file view-based nstableview, in delegate have setup:
class myviewcontroller: nsviewcontroller, nstableviewdelegate, nstableviewdatasource, nsdraggingdestination { @iboutlet var tableview: nstableview! // connected in storyboard. override func viewdidload() { super.viewdidload() tableview.registerfordraggedtypes([nsfilenamespboardtype]) // … } func draggingentered(sender: nsdragginginfo) -> nsdragoperation { println("drag entered.") return .copy } func preparefordragoperation(sender: nsdragginginfo) -> bool { return true } func draggingupdated(sender: nsdragginginfo) -> nsdragoperation { return .copy } // ... }
but program refuses react drag-n-drop. when drag file finder , release, file icon flies finder. missing in code?
update: added this
func performdragoperation(sender: nsdragginginfo) -> bool { return true }
but still doesn’t work. should implement in view instead of delegate? document says “either window object or delegate may implement these methods;”
if @ sample code apple puts in "receiving drag operations" documentation, last function put there implementation of:
- (bool)performdragoperation:(id <nsdragginginfo>)sender
you need implement , return "yes
" indicate drag succeeded.
Comments
Post a Comment