首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拖放不适用于NSBox的子类

拖放不适用于NSBox的子类
EN

Stack Overflow用户
提问于 2009-09-17 00:34:03
回答 1查看 725关注 0票数 2

我已经创建了NSBox的一个子类来实现拖放。我有以下代码:

代码语言:javascript
复制
@interface DropView : NSBox {

}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender;
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
@end

@implementation DropView
- (void)awakeFromNib
{
    [self registerForDraggedTypes:
  [NSArray arrayWithObject: NSFilenamesPboardType]];
}
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
 NSDragOperation sourceDragMask = [sender 
           draggingSourceOperationMask];
 if (sourceDragMask & NSDragOperationLink) {
  return NSDragOperationLink;
 } else if (sourceDragMask & NSDragOperationCopy) {
  return NSDragOperationCopy;
 }
 return NSDragOperationNone;
}

-(BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
 NSPasteboard *pboard=[sender draggingPasteboard];
 NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
 NSEnumerator *e=[files objectEnumerator];
 NSString *str=nil;
 while(str=[e nextObject]) {
  NSLog(@"Got %@\n", str);
 }

 return (TRUE);
}
@end

但是,拖放不起作用。当我试图把东西拖到盒子里时,我看不到绿色的小加号。

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-09-17 00:53:53

已修复此问题。没有将NSView的类设置为DropView,而是将NSBox的类设置为DropView :-)

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

https://stackoverflow.com/questions/1436175

复制
相关文章

相似问题

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