在NSView中放置位置 [英] Drop location in NSView

查看:87
本文介绍了在NSView中放置位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Cocoa应用程序(XCode 7.0.1),其中有一个NSTableView和一个NSView。设计该应用程序的原因是为什么我们可以将项目从NSTableView拖放到NSView中。

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.

拖放工作正常,但是我只能注册某些东西被放置在NSView上,而不是放置在NSView上。我想知道是否有一种方法可以在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?

我尝试了NSView可以拥有的所有鼠标事件,但它们没有似乎在拖动操作期间被调用。

I have tried all mouse events that NSView can have but they don't seem to be called during the drag operation.

更准确地说,我使用


  • (NSDragOperation)draggingEntered :( id)sender;


  • (BOOL)performDragOperation:(id)sender;

使用NSView接收拖动操作。

To receive the drag operation with NSView.

推荐答案

发件人符合NSDraggingInfo协议,并实现-(NSPoint)draggingLocation [发送者draggingLocation] 返回鼠标指针在目标对象窗口的基本坐标系中的当前位置。

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.

这篇关于在NSView中放置位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆