首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >writeRowsWithIndexes不使用自定义单元格在NSTableView中调用

writeRowsWithIndexes不使用自定义单元格在NSTableView中调用
EN

Stack Overflow用户
提问于 2014-09-09 12:27:05
回答 1查看 589关注 0票数 0

我已经实现了以下委托,以支持NSTableView中的拖放。委托、validateDrop和acceptDrop都会被调用,我可以将内容从Finder拖放到NSTableView,但是当我尝试将项目从NSTableView拖放到Finder时,writeRowsWithIndexes不会被调用。

代码语言:javascript
运行
复制
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
  NSLog(@"writeRowsWithIndexes");
  return YES;
}

- (NSDragOperation)tableView:(NSTableView *)aTableView validateDrop:(id < NSDraggingInfo >)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)operation
{
 NSLog(@"validateDrop");
 return NSDragOperationCopy;
}

- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id < NSDraggingInfo >)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)operation
{
NSLog(@"acceptDrop"); 
return YES;
}

我已将拖动类型注册为

代码语言:javascript
运行
复制
//Registering dragged Types
[tableView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
//To support across application passing NO
[tableView setDraggingSourceOperationMask:NSDragOperationCopy forLocal:NO];
//Don't want any highlight selection on drop
[tableView setDraggingDestinationFeedbackStyle:NSTableViewDraggingDestinationFeedbackStyleNone];

拖动在我的NSTableView中没有启动,有人能告诉我可能的原因是什么吗?我在TableView中有自定义单元格,并且正确设置委托和数据源。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-10 13:09:45

我找到了原因,是因为定制的细胞。我已将我的自定义单元格从NSButtonCell中子类化。拖动不适用于按钮单元格,因为按钮不是用来拖动的,而是用来照明的。我通过将我的自定义单元格从NSActionCell中子类来解决这个问题。

在下面的文章中可以找到:NSTableView Drag and Drop not working

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25744650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档