org.eclipse.rap
org.eclipse.rap copied to clipboard
selection in not yet focused multiline Text widget
There is a textarea (Text widget with SWT.MULTI), which contains a lot of text (vertical scrollbar is visible).
The sequence of events to cause the error is as follows:
- Use Edge or Chrome
- The textarea has to be unfocused.
- Use the mouse wheel to scroll down in order to see the last lines of the text (By this action, the field will not get the input focus)
- Now try to select a few lines from the now visible portion of text by clicking into the field and selecting some text.
Expected result: The text is correctly selected.
Actual result: When you click into the field, the field will scroll to the top of the text before the selection is applied. When the mouse is moved to expand the selection, this will be done based on the position of the mouse cursor in the then scrolled-to-top textarea, which is not what the user expects. This seems to be due to the default behavior of the Edge/Chrome(?) browser in the textarea.focus() method and the fact that the current selection in the onfucsed textarea will be at position 0.
The issue is also described and was discussed here: https://www.eclipse.org/forums/index.php/t/1112437/
My idea for a solution would be not execute the inputElement.focus() call in the mouse activation.
Best regards, Gunnar Adams
The order of events are focus than mouse. The automatic scrolling to the current selection is browser native behavior, which I didn't manage to prevent. For your specific use case I would suggest to patch the JavaScript code (at startup or runtime with JavaScriptExecutor service) and override the function _visualizeFocus on the text widget on the client to empty implementation.
Thank you for looking into it. I will try to implement your suggestion.