问题
I'm writing a Cocoa Application (XCode 7.0.1) and within it, I have a NSTableView and a NSView. The application is designed in a why that we can drag and drop items from the NSTableView into the NSView.
The drag and drop works properly, but I can only register that something is dropped on the NSView and not where in the NSView. I was wondering if there is a way to get the location of the drop within the frame of NSView?
I have tried all mouse events that NSView can have but they don't seem to be called during the drag operation.
To be more precise, I use
- (NSDragOperation)draggingEntered:(id )sender;
and
- (BOOL)performDragOperation:(id )sender;
To receive the drag operation with NSView.
回答1:
sender conforms to the NSDraggingInfo protocol and implements -(NSPoint)draggingLocation
. [sender draggingLocation]
returns the current location of the mouse pointer in the base coordinate system of the destination object’s window.
来源:https://stackoverflow.com/questions/32971540/drop-location-in-nsview