[Gambas-user] Getting selected HTML in a WebView control (was Re: WebView1_MouseDown() question)
Benoît Minisini
gambas at ...1...
Thu Aug 25 03:44:06 CEST 2011
> On Tuesday 23 August 2011 23:47:33 Benoît Minisini wrote:
> > > This code I got I think from the webview demo some time ago:
> > > If hTest.Selected Then
> > >
> > > Clipboard.Copy(Webview1.SelectedText)
> > > Print webview1.SelectedText
> > >
> > > End If
> > >
> > > If the webview contains html, then the print webview1.selected text
> > > prints out plain text.
> > >
> > > Is there anyway I can capture the html of the text? into a variable. It
> > > must be around somewhere because if I select the text, due a ctrl
> > > copy, and then paste it into a textarea with the middle mouse button,
> > > then it is pasted as formatted html.
> > >
> > > REgards
> > >
> > > Richard
> >
> > Apparently there is no way in QtWebKit to retrieve the HTML selected
> >
> > text... I will investigate.
> >
> > And please if you can use a mail subject that is related to its contents!
> >
> > Regards,
Hi, Richard.
I have added a WebView.Eval() method in the last revision. That method allows
you to evaluate any JavaScript method in the context of the web page.
That way, I think you may get the selected HTML. But I don't know the DOM API
enough to tell you if there is a method for that.
The following hack may work anyway:
WebSettings[WebSettings.JavascriptCanAccessClipboard] = True
MyWebView.Eval("document.execCommand('Copy', false, null)")
Print Clipboard.Paste("text/html")
But the returned HTML is not pretty...
Regards,
--
Benoît Minisini
More information about the User
mailing list