NSTableView 可以处理普通的拖放方法吗?

发布于 2024-11-28 17:56:43 字数 981 浏览 3 评论 0原文

我想使用 NSTableView 而不 NSTableViewDataSource 方法,但就像普通视图一样。 draggingEntered:draggingExited: 正在被调用,但是当我返回 NSDragOperationCopy 时,我看不到绿色加号鼠标指针和 performDragOperation : 没有被调用。

我使用以下方法对 NSTableView 进行了子类化:

- (void)awakeFromNib
{
    [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]];
}

- (NSDragOperation)draggingEntered: (id < NSDraggingInfo >)sender
{
    NSLog(@"draggingEntered"); //Gets called
    return NSDragOperationCopy;
}

- (void)draggingExited: (id < NSDraggingInfo >)sender
{
    NSLog(@"draggingExited"); //Gets called
}

- (BOOL)performDragOperation: (id < NSDraggingInfo >)sender
{
    NSLog(@"performDragOperation"); //Doesn't get called
    return YES;
}

I'd like to use NSTableView without the NSTableViewDataSource Methods but just like a normal view. draggingEntered: and draggingExited: are being called but when I return NSDragOperationCopy, I don't see the green plus mouse pointer and performDragOperation: doesn't get called.

I subclassed the NSTableView with these methods:

- (void)awakeFromNib
{
    [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]];
}

- (NSDragOperation)draggingEntered: (id < NSDraggingInfo >)sender
{
    NSLog(@"draggingEntered"); //Gets called
    return NSDragOperationCopy;
}

- (void)draggingExited: (id < NSDraggingInfo >)sender
{
    NSLog(@"draggingExited"); //Gets called
}

- (BOOL)performDragOperation: (id < NSDraggingInfo >)sender
{
    NSLog(@"performDragOperation"); //Doesn't get called
    return YES;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

通知家属抬走 2024-12-05 17:56:44

文档说它符合 NSDraggingDestination 和 NSDraggingSource 协议,所以是的,它应该进行正常的拖放操作。

您可以尝试使用 nsview 中的 -registerForDraggedTypes: 方法。

The documentation says it conforms to the NSDraggingDestination and NSDraggingSource protocol, so yes it should hand normal drag-and-drop.

You might try using -registerForDraggedTypes: method from nsview.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文