Drag from NSOutlineView never accepted
I'm trying to implement dragging from an NSOutlineView and although the drag starts OK it is never accepted by another app. The pertinent code is:
- (BOOL) outlineView:(NSOutlineView*)pOutlineView writeItems:(NSArray*)pItems toPasteboard:(NSPasteboard*)pBoard
{
CItem* theItem = [pItems objectAtIndex:0];
BOOL canDrag = ([theItem subItems] == 0);
if (canDrag) {
[pBoard clearContents];
[pBoard writeObjects:[NSArray arrayWithObject:[theItem name]]];
}
return canDrag;
}
[theItem name] returns an NSString*. At some point I'll want to add more to the pasteboard contents b开发者_运维问答ut until I can get it to work with a simple string there doesn't seem to be much point in getting into that.
The drag looks fine but the receiver doesn't show any highlighting when being hovered over and the drag image 'flies back' when released.
Any help gratefully received!
Rev. Andy
Turns out that draggingSourceOperationMaskForLocal: is never called for the delegate of NSOutlineView (or NSTableView possibly) so that drag operation is never allowed. Subclassing NSOutlineView just to override this method fixes everything.
精彩评论