Community
Participate
Working Groups
I20050803-0800 In a Text widget with text "abc", the behavior of #setSelection(int, int) depends on whether the flag SWT.SINGLE is set. - with SWT.SINGLE, setSelection(3,1) sets the caret to position 3 - without SWT.SINGLE, setSelection(3,1) sets the caret to position 1 The second behavior should also apply for the SWT.SINGLE case. This would also match the documented behavior of StyledText#setSelection(int, int).
Sorry, it's not possible to set the i-beam location to the start or end of the selection on Windows. Hence, the behavior is not specified.
It seems that the behavior has changed (didn't verify that the initial comment 0 was true though): now (3.4 M5) the caret is always on the right side no matter whether SWT.SINGLE is used or not. Is there really no way/API on Windows to set a RTL selection?
>It seems that the behavior has changed Not if the selection is set after opening the shell.
Ok, there is a work around that doesn't set the selection to fix the classic "widget is zero sized, I set the selection, the widget scrolls, I resize the widget then I'm mad when the widget is scrolled" bug. It sets the selection and probably doesn't get the i-beam in the right place. Can you confirm that this is what is going on? (ie. this is the behavior change)
(In reply to comment #4) I don't think there really was a behavior change. Dani got tricked by a snippet that sets the selection before opening the shell. In that case, the caret always ends up at the end of the selection. But that's a different problem and not the subject of this bug. The problem as described in comment 0 happens when the text widget is already visible (e.g. reproducible in the ControlExample). To implement bug 64665, I had to use a rather drastic workaround: I implemented all selection change actions from scratch and introduced a "logical" caret position, which does not match the visible caret. That does not look nice, but it works as long as the user only changes the selection via keyboard.
>I don't think there really was a behavior change. Dani got tricked by a snippet >that sets the selection before opening the shell. So it is.
Same is true for Combo.