Objective c NSImageView拖放仍在窗口边界外工作
我有一个NSImageView,拖放连接如下:Objective c NSImageView拖放仍在窗口边界外工作,objective-c,drag-and-drop,nsimageview,Objective C,Drag And Drop,Nsimageview,我有一个NSImageView,拖放连接如下: -(NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender{ if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric) { return NSDragOperationGeneric;
-(NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender{
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask])
== NSDragOperationGeneric) {
return NSDragOperationGeneric;
} // end if
// not a drag we can use
return NSDragOperationNone;
}
-(NSDragOperation) draggingUpdated:(id<NSDraggingInfo>)sender{
return NSDragOperationCopy;
}
-(void) draggingEnded:(id<NSDraggingInfo>)sender{
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] )
{
NSArray *files = [pboard
propertyListForType:NSFilenamesPboardType];
// Loop through all the files and process them.
for( int i = 0; i < [files count]; i++ )
{
....
}
}
这一切都很好。当从Finder中拖动fils时,如果在视图内,则指示加号;如果在视图外,则删除加号。它还指示在一个小气泡中要复制多少文件。所有这些都很有效。但是,如果我在视图上拖动,并在应用程序外部拖动,则加号会消失,但在发布时,它仍会将文件拖放到视图中。我怎样才能阻止这种行为
非常感谢您的建议。我想我已经找到了解决方案 我没有使用Draggineded,而是使用performDragOperation和所有作品