1

I am trying to change the color for some of the text in my GWT Text Area. I know the start and end of the text I want to change the color.

Now Is there any way I can change the color (apply some css) to the text in that location.

example.. This is the text in my GWT Text Area

"Hello, this is an example"

Now the words 'an example' need to be in red color.

Thanks

junaidp
  • 10,801
  • 29
  • 89
  • 137

1 Answers1

0

GWT implementation of TextArea is just call to DOM for a creation of an HTML TextArea Object. Thus, GWT object has the same limitations as HTML object.

Try with RichTextArea that allows complex styling and formatting.

Braj
  • 46,415
  • 5
  • 60
  • 76
  • Thanks , I also need cursorPosition which is not in RichTextArea. – junaidp Jun 19 '14 at 06:23
  • Are you sure? Let me check for cursor position. – Braj Jun 19 '14 at 06:24
  • yeah, cant find cursor position in RichTextArea – junaidp Jun 19 '14 at 06:27
  • 1
    @junaidp `RichTextArea` doesn't provide methods to get/set the cursor position. But there are other SO questions with JSNI solutions [here](http://stackoverflow.com/questions/12542522/how-to-get-cursor-position-or-location-from-richtextarea-in-gwt) and [here](http://stackoverflow.com/questions/12549739/how-to-setcursor-position-in-gwt-richtextarea). – Baz Jun 19 '14 at 08:07
  • Using this JSNI approach, Not much experience of JSNI, Should i pass richTextArea in this method instead public static native JsArrayString getSelection(Element elem) /*-{ instead of Element.. I tried changing Element to RichTextArea when i run , it gives null error – junaidp Jun 19 '14 at 09:20
  • have you tried all the possible solutions posted by @Baz in both the links? Take your time and read here about [JSNI](http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsJSNI.html) – Braj Jun 19 '14 at 09:23