Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
How to retrieve selected text in ui.WebView?
-
Hi, is it possible to get the currently selected text inside a
ui.WebView
? I am aware that I could copy the text manually to the clipboard and then retrieve its content with Python but I would like to avoid that additional step. I was hoping for some ObjC magic, so that I could invoke the WebViews Edit menue copy function programmatically.Cheers
zipit -
No need for
objc_util
, you can use JavaScript:selected_text = web_view.eval_js('document.getSelection().toString()')
-
Oh, thanks, that was quick!