我想使用不带the NSTableViewDataSource Methods的NSTableView,但就像普通视图一样。正在调用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;
}发布于 2011-08-10 05:55:00
文档说它符合NSDraggingDestination和NSDraggingSource协议,所以是的,它应该使用普通的拖放。
您可以尝试使用nsview中的-registerForDraggedTypes: method。
https://stackoverflow.com/questions/7001332
复制相似问题