What method is available to select text on webkit2gtk. I could not find anything on the API for Vala webkit2: https://valadoc.org/webkit2gtk-4.0/WebKit.WebView.html

The requirement is to get the selected text on a webpage after the user releases the mouse after text selection.

  • 1
    You'd probably have better luck with this question on Stack Overflow. Also, it's really more of a WebKit question than a Vala question, so don't forget the webkit and webkitgtk tags.
    – nemequ
    Sep 27, 2017 at 0:30
  • Many thanks, asked the question here - stackoverflow.com/questions/46442869/… Sep 27, 2017 at 8:25

1 Answer 1


Based on the response here, I'm concluding that there is no direct way to interact with the DOM in WebKit2GTK. The work around is to use the following:

  1. Run a javascript function using WebView.run_javascript
  2. Within the javascript function, assign the result to document.title
  3. Fetch the results back using the WebView.get_title()

Seems a bit roundabout way, but it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.