Text widget, key event and caret position [message #845868] |
Sun, 15 April 2012 13:52 |
Arnaud MERGEY 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03729 seconds