Drop location in NSView

[亡魂溺海] 提交于 2019-12-12 03:59:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!