Hey thanks,

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...
>
> On Jan 1, 11:07 pm, Trevis <trevistho...@gmail.com> wrote:
>
> > I feel like i must be missing something obvious but i'm not seeing any
> > convenience method to get the selected text. Seems too obvious to be
> > an oversight. Any help would be much appreciated.
>
> > Trevis
>
> > On Dec 31 2009, 9:26 am, Trevis <trevistho...@gmail.com> wrote:
>
> > > I'd like to create a custom rich text aera. I think I I've got a fair
> > > handle on how it works from playing with the showcase RichTextToolbar
> > > source code. The Formatter.insertHtml method seems like it will get
> > > almost exactly what i need. But, there is one critical peice of the
> > > puzzle I have yet to solve.  I need to grab the text that the user has
> > > selected to make the HTML inserts  work he way I need them to.
>
> > > Am I missing it? How can I get the selected text?

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to