I need to get the selected text from webView in javaFX. I have not found any clue how to do it on the internet.
This can be done with JavaScript:
String selection = (String) webView.getEngine()
.executeScript("window.getSelection().toString()");
System.out.println(selection);
Also you may find this helpful:
Communicating between JavaScript and JavaFX with WebEngine
executeScript
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With