Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 13:52 Go to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
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 149 times)
  • Attachment: rwtpatch.txt
    (Size: 2.62KB, Downloaded 301 times)

[Updated on: Sun, 15 April 2012 13:57]

Report message to a moderator

Re: Text widget, key event and caret position [message #846698 is a reply to message #845868] Mon, 16 April 2012 15:19 Go to previous messageGo to next message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1313
Registered: July 2009
Senior Member

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 12:28 Go to previous message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 243
Registered: March 2010
Location: France
Senior Member
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: Fri Apr 26 22:20:13 GMT 2024

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

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

Back to the top