Reputation: 22810
OK, so here's what I need (though I still have found no real answer to my questions) :
WebView
WebView
.I've tried via the WebUIDelegate
and its methods, even registerForDraggedTypes
, but still without success.
Any ideas? Is there anywhere a complete example of how this can be achieved?
Upvotes: 0
Views: 157
Reputation: 3805
I did it in my application, followings are the key points, if you still looking for it,
Let it accept drop into the webview
[self registerForDraggedTypes:
[NSArray arrayWithObjects:MyPrivateTableViewDataType,NSFilenamesPboardType,nil]];
Handle Dragging entered to verify / validate the item which is being dragged.
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender{
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
if (sourceDragMask & NSDragOperationGeneric) {
return NSDragOperationGeneric;
}
}
}
- (BOOL)prepareForDragOperation:(id < NSDraggingInfo >)sender{
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
// Only a copy operation allowed so just copy the data
return YES;
}
else if ( [[pboard types] containsObject:NSURLPboardType] ) {
return YES;
}
return NO;
}
and finally perform/complete the drag-drop
- (BOOL)performDragOperation:(id < NSDraggingInfo >)sender{
NSPasteboard *pboard;
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:MyPrivateTableViewDataType] ) {
// Only a copy operation allowed so just copy the data
return YES;
}
else{
return NO;
}
} else if ( [[pboard types] containsObject:NSURLPboardType] ) {
NSURL *url = [NSURL URLFromPasteboard: pboard];
NSString *filePath= [url path];
return YES;
}
return NO;
}
Upvotes: 1