Re: How to get selected text in a WebView
Re: How to get selected text in a WebView
- Subject: Re: How to get selected text in a WebView
- From: Keary Suska <email@hidden>
- Date: Mon, 4 Oct 2010 11:45:02 -0600
On Oct 4, 2010, at 1:15 AM, Gerriet M. Denkmann wrote:
> I have a Webview, and I want to do something with the selected text.
>
> I tried:
> DOMRange *dr = [ webView selectedDOMRange ];
> NSString *m = [ dr markupString ];
> this contains the selected characters, but buried in lots of markup language. But I just want the characters.
>
> NSString *s= [ dr stringRepresentation ];
> just returns "Undefined".
>
> I could do [webView copy:nil ]; and then get the string from the general pasteboard, but I rather do not like to mess up the pasteboard - the user might have put something important there.
The first thing I would try is use NSAttributedString to convert the HTML.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden