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