Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Text widget, key event and caret position
Text widget, key event and caret position [message #845868] Sun, 15 April 2012 09:52 Go to next message
Eclipse UserFriend
Hello,

It seems this has already been discused, but I cannot find pointers about this.

I noticed calling setSelection on a Text widget during a key event processing is not reflected in browser

For example executing this code:

public void keyPressed(KeyEvent e) {
if(e.keyCode == SWT.PAGE_UP){
StringBuilder builder = new StringBuilder(text.getText());
int index = text.getSelection().x;
char c = text.getText().charAt(index);

builder.setCharAt(index, ++c);
text.setText(builder.toString());
text.setSelection(index);
}
}

Caret position on server side and client side are not sync. On Browser side, it is at the end of the text. The reason for that is org.eclipse.rwt.lifecycle.ControlLCAUtil.processKeyEvents(Control) does not preserve selection property (I understand the reason is selection is not a generic property for control)

The attached application illustrate this behavior, put the caret somewhere in the Text widget (in view) and press key PageUp, the text is updated and the caret position go to the end.
If I apply the given patch in RWT (it is just for testing purpose), Text keep its position.

Do you think it can be considered as a bug ? or do you know a way to workaround this ?

Thanks,
Regards,
Arnaud



  • Attachment: testapp.zip
    (Size: 14.84KB, Downloaded 174 times)
  • Attachment: rwtpatch.txt
    (Size: 2.62KB, Downloaded 329 times)

[Updated on: Sun, 15 April 2012 09:57] by Moderator

Re: Text widget, key event and caret position [message #846698 is a reply to message #845868] Mon, 16 April 2012 11:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi Arnaud,

If the caret position (i.e. the selection) runs out of sync between
client and server, this is very likely a bug. Could you file a bug
report including your snippet?

The code you've posted looks like a perfect case for the new client
scripting [1]. This would avoid the need for a request with every
keystroke and instead change the text and selection directly on the
client. If you use RAP 1.5, you might give it a spin.

Best regards, Ralf

[1] http://wiki.eclipse.org/RAP/ClientScripting


--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Text widget, key event and caret position [message #847562 is a reply to message #846698] Tue, 17 April 2012 08:28 Go to previous message
Eclipse UserFriend
Thanks for the pointer to ClientScripting Ralf, it is really helpful.

regarding the issue, I have created bug 376960
Previous Topic:Control positions are wrong ?
Next Topic:RAP application with XWT
Goto Forum:
  


Current Time: Sat Jun 21 02:00:01 EDT 2025

Powered by FUDForum. Page generated in 0.08612 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top