NSTableView 可以处理普通的拖放方法吗?
我想使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文档说它符合 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.