Friday, January 4, 2013

How to modify Enter key behavior in RichTextArea?

Pressing the Enter key in RichTextArea creates a new line (and adds '<br><br>' to the html content) but if the Ctrl key is down then it doesn't.  That makes sense for normal text editing but I want to basically reverse that.  Where is this behavior coded?  Is that controlled in GWT code or is that just the behavior of the browser? 

I tried overriding onBrowserEvent() and adding '<br><br>' if the control key is down but that didn't help.

Then I went looking for a setCursorPosition method on RichTextArea but didn't find one.  It seems lots of folks have asked for that.

What's the best way to solve this?  Is there some custom setSelectionRange() logic out there for setting the cursor position?  I found a couple of JSNI examples of this but they didn't work...perhaps because my browser is too new, not sure.

-Dave

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

No comments:

Post a Comment