I have a number of objects that handle Drops, all of their code is descended from a single object where I noticed an oddity in Drag n drop behavior. That that is, if I do not add a particular set of lines to the performDrop method, the pasteboard appears to be empty.
what gives?
forgive formatting and code issues. it works just fine, but I had a heck of a time fixing the formatting in the Forum editor. There's likely now, a LOT of text that used to be comments... how could that be any worse? Anyway, "if let newPlistData = pasteBoard.propertyList(forType: CNDragTypeToolBox){}" is the line. if that is not called, the drop pasteboard is empty, if it is called, my objects are there.
I don't need that object, it has nothing at all to do with anything I am doing. Why is it necessary?
also: @Apple... you really messed up the forums. this is so difficult to work with.
what gives?
Code Block open override func performDragOperation(_ sender: NSDraggingInfo, forCon: BKLayerController) -> Bool{ var retVal = false let paneRec = forCon.rep as! CNPanelRecord let pasteBoard : NSPasteboard = sender.draggingPasteboard if pasteBoard.types?.contains(CNDragTypeToolBox) == true{ retVal = true let encoder = JSONEncoder() let thePoint = CGPoint() /* if I do not add this if statement... drag n drop does not work */ if let newPlistData = pasteBoard.propertyList(forType: CNDragTypeToolBox){} let payload = pasteBoard.readObjects(forClasses: [pBoardNode.self], options: nil) let droppedItems : [CNDagObj] = (payload as! [pBoardNode]).map({$0.docNode.dagObjs}).flatMap { $0 } for each in droppedItems{ each.uuid = UUID().uuidString do { let ptData = try encoder.encode(thePoint) if let env = paneRec.focus as? CNEnvelopment{ env.dagObjPos[each.uuid] = ptData } } catch { debugPrint("tring to convert a Point to a Data, in updateLayout in CDEditorDel") } } if var env = paneRec.focus as? CNEnvelopment{ env.dagObjs += droppedItems } } return retVal }
forgive formatting and code issues. it works just fine, but I had a heck of a time fixing the formatting in the Forum editor. There's likely now, a LOT of text that used to be comments... how could that be any worse? Anyway, "if let newPlistData = pasteBoard.propertyList(forType: CNDragTypeToolBox){}" is the line. if that is not called, the drop pasteboard is empty, if it is called, my objects are there.
I don't need that object, it has nothing at all to do with anything I am doing. Why is it necessary?
also: @Apple... you really messed up the forums. this is so difficult to work with.