Am I missing it? How can I get the selected text?
Trevis
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ae9a0ebff58a8f15
On Jan 1, 11:07 pm, Trevis <trevistho...@gmail.com> wrote:
I've seen that post which was what turned me on to RichTextToolbar
when i started to research this a couple of days ago. It looks great
and will definitely be the inspiration for how i create mine. The
problem is i want to do custom functionality that the raw Formatter
object doesn't supply. (custom youtube and embeding and a few more
things) which i can do just perfectly with insertHTML. The problem
is, i want to grab the text that the user has highlighted so that i
can use it when i insert the custom html but the API doesnt seem to
expose it. The custom RichTextToolbar implementation just calls
methods on RichTextArea and never actual seem to touch the selected
text directly. It just calls things like
RichTextArea.Formatter.createLink... which hands wrapping the selected
text internally.
I just wrote a hack work around for the time being so that i can
progress to other work but i'm still convinced that a getSelectedText
method exists somewhere. If it doesnt, it certainly should.
Here's the workaround that i just came up with:
private String crazyGetSelectedText(RichTextArea
rta) {
final String MARKER = "http://trevsmarker.com";
rta.getFormatter().createLink(MARKER);
String withMarker = rta.getHTML();
int markerIndex = withMarker.indexOf(MARKER);
int beginIndex = withMarker.indexOf('>', markerIndex)+1;
int endIndex = withMarker.indexOf('<', beginIndex);
String selected = withMarker.substring(beginIndex, endIndex);
rta.getFormatter().removeLink();
return selected;
}
That seems to get the job done but how horribly inefficient is that
solution?
Trevis
On Jan 1, 12:11 pm, Anoop John <anoopjoh...@gmail.com> wrote:
> Tevis Please see the post below.
>
> http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa...