Get the cursor position in TextArea?

83 views
Skip to first unread message

membersound

unread,
Mar 7, 2013, 9:02:02 AM3/7/13
to google-we...@googlegroups.com
Hi,

can I know from the backing code where the cursor in the TextArea is placed? Eg to extract the text that is in front of the cursor, and after it.

Also, is it possible to format a text to be displayed differently than the backend source holds the text? Eg if I have a comma-separated list, can I keep that list in backend with commas, but display it in UI without commas?

Thanks

Jens

unread,
Mar 7, 2013, 9:13:40 AM3/7/13
to google-we...@googlegroups.com

can I know from the backing code where the cursor in the TextArea is placed? Eg to extract the text that is in front of the cursor, and after it.

TextArea.getCursorPos() ?
 

Also, is it possible to format a text to be displayed differently than the backend source holds the text? Eg if I have a comma-separated list, can I keep that list in backend with commas, but display it in UI without commas?

You can freely format your text before setting it into the TextArea and you can also freely format the text for your backend after you have retrieved it from the TextArea. So just add and remove commas the way you want it.

-- J.

Kody

unread,
Mar 7, 2013, 2:03:21 PM3/7/13
to google-we...@googlegroups.com
Ups, I missed the getCurserPos(). Thanks!

Anyways: yes I know I can modify the box text back and forth. But I'm more looking in some type in Formatter or something like that. Just like eg Numbers or Dates can be displayed differently in the UI though their value stays the same in the backend.


2013/3/7 Jens <jens.ne...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/D9PfjznCy3w/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jens

unread,
Mar 7, 2013, 2:30:27 PM3/7/13
to google-we...@googlegroups.com
You can use com.google.gwt.text.shared.Renderer/Parser or roll your own Formatter to implement the back and forth logic and then you could also create a custom TextArea that requires a Renderer/Parser or your custom Formatter.

Shouldn't be too difficult.

-- J.

membersound

unread,
Mar 7, 2013, 5:09:28 PM3/7/13
to google-we...@googlegroups.com
Is there any function to return the XY Pixel coordinates for the cursor? Or at least the pixel position inside the widget like TextArea so that I could calculate the absolute XY?
Reply all
Reply to author
Forward
0 new messages