[Gambas-user] gb.webkit Webview current element

Bruce bbruen at ...2308...
Sat Sep 29 04:28:53 CEST 2012


On Sat, 2012-09-29 at 03:41 +0200, Benoît Minisini wrote:
> Le 29/09/2012 02:26, Bruce a écrit :
> > Morning all,
> >
> > Does anyone know a way to get the html element under the mouse pointer
> > in the webview on a MouseDown or MouseUp event?  I have been through
> > much of the webkit site and the w3schools javascript site and can't find
> > anything that seems to offer this.
> >
> > tia
> > Bruce
> >
> 
> At the moment gb.qt4.webkit don't provide any access to the underlying 
> DOM and HTML structure of the page.
> 
> You can only use the WebView.HitTest() method to know if the mouse is on 
> an image, a selected contents, an editable contents or a link, and in 
> that last case you can get the link URL.
> 
> Some work could be done there. Do you really need a full access to the DOM?
> 
Hi Benoît,

I can access the DOM, or at least the interesting part, with
webview.Eval("document.body.innerHTML"). Which I can then use with
gb.xml.html to get a useable DOM. (I think! I haven't tried that yet.)  

The problem is detecting which element is under the mouse pointer, so I
can position myself in that DOM.  Even some sort of offset value giving
the position of the mouse pointer into the document html would help.

Webkit, itself must have a way to do this as the webinspector has that
little tool at the bottom to highlight elements as the mouse moves over
the page (see pic attached).

regards
Bruce

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Selection_006.png
Type: image/png
Size: 263778 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20120929/3805d314/attachment.png>


More information about the User mailing list