Hi Guys,
I'm using a WebView in my app on mac 10.8 to be used as a text editor, a la mail.app.
I have most of what I need, but I'm now facing an issue. I try to move around, in editing mode, the content of my webview. If I select text from the webview, it works fine, the text is drawn during the drag under the mouse, the caret moves under the mouse, and the text is moved to where I released my button.
Now if I try to drag around an instance of my plugin (used to display as an HTML <object/> an icon with its filename) , nothing happens, the drag is not initiated.
I tried to initiate the drag manually with this piece of code:
DOMRange *selection = [self.myWebview selectedDOMRange];
if (selection == nil)
return;
BOOL selected = ((NSNumber *)[self.currentDOMInformations objectForKey:WebElementIsSelectedKey]).boolValue;
if (selected)
{
NSPasteboard *pboard;
NSArray *types = [[NSArray alloc] initWithObjects:WebArchivePboardType, nil];
pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
[pboard addTypes:types owner:self];
//[pboard clearContents];
[pboard setData:[selection.webArchive data] forType:WebArchivePboardType];
NSImage *image = [NSImage imageNamed:template];
NSPoint mouseLocation = theEvent.locationInWindow;
[self.myWebview dragImage:image at:mouseLocation offset:NSMakeSize(0, 0) event:theEvent pasteboard:pboard source:self.myWebview slideBack:YES];
}
}
It works in the sense that I can now drag the content around (albeit with a default image), but dropping actually copies the content instead of moving it. And the selection ends up garbaged as the drop seems to prevent my webview from processing any new input (keyboard) until I click somewhere in the webview to move the caret.
I read on StackOverflow that WebView was one of the most complex views in osx, and I tend to agree ;-), so could you let me know if I'm even on the right path?
Many thanks;
Olivier./.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20121029/27afd83f/attachment.html>