TextArea vs RichTextArea

97 views
Skip to first unread message

jimakos17

unread,
Oct 9, 2012, 9:18:57 AM10/9/12
to google-we...@googlegroups.com
I am trying to create an area and initially I used the RichTextArea in order to use functions like toggleBold, toggleItalic and toggleUnderline.
After a few days I noticed that in comparison with the TextArea, there are no getCursorPos and getSelectedText methods which are very essential
in order to handle my editor.
Do you know if there is any way to combine these functionalities or how can I use getCursorPos and getSelectedTextin in RichTextArea?
Thank you very much.

jimakos17

unread,
Oct 10, 2012, 12:11:42 PM10/10/12
to google-we...@googlegroups.com
I tried to include the getCursorPos() of TextArea in RichTextArea

private static RichTextAreaImpl impl = GWT.create(RichTextAreaImpl.class);

public int getTextAreaCursorPos(Element elem)
{
   
return getCursorPos(elem);
}
public int  getCursorPos()
{
   
return getTextAreaCursorPos(getElement());
}

protected RichTextAreaImpl getImpl()
{
   
return impl;
}

public native int getCursorPos(Element elem)
/*-{
    // Guard needed for FireFox.
     try{
       return elem.selectionStart;
     } catch (e) {
       return 0;
     }
 }-*/
;


but due to JSNI I can't figure out what's going on with selectionStart.

elem.selectionStart returns always 0

Please any idea? Thank you!!!

jimakos17

unread,
Oct 11, 2012, 5:38:49 AM10/11/12
to google-we...@googlegroups.com
anyone please...

Jens

unread,
Oct 11, 2012, 7:46:35 AM10/11/12
to google-we...@googlegroups.com
There are at least two (old) issues for it:


In the comments someone mentioned that he has created a library: http://code.google.com/p/gwt-selection/

Maybe you should try it.

-- J.

Jens

unread,
Oct 11, 2012, 7:50:01 AM10/11/12
to google-we...@googlegroups.com
And searching in google gives me the following result: 


Maybe that also works for you.

-- J.
Reply all
Reply to author
Forward
0 new messages