Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 337905

Summary: StyledText shows blinking caret when text is selected (violates native text editing behavior)
Product: [Eclipse Project] Platform Reporter: Doug M <eclipse>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: arronm
Version: 4.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard: stalebug

Description Doug M CLA 2011-02-22 16:37:25 EST
Build Identifier: swt-3.7M5-cocoa-macosx-x86_64

Left-to-right selection highlights text and blinks caret at the right end of selection. Right-to-left selection highlights text and blinks caret at left left end of selection. I can't find any other text editor that acts this way. Ordinary users are likely to be both surprised and confused by this behavior.

Modern selection/caret behavior goes like this:
- There is a single selection in a text area.
- Typing replaces the selection.
- When the selection contains characters, they are highlighted (no caret).
- When the selection is empty, a blinking caret is shown to make the empty selection point visible.
- Left/right arrow keys set an empty selection (caret) at the left/right end of the selection.

In sum, the caret is a visible representation of the selection when it is empty. OS X TextEdit, Windows WordPad, MS Word, and various text processors and browsers all follow this convention. 

Therefore, it's unexpected and confusing for StyledText to show the user a selection and caret at the same time. Since the rest of StyledText's behavior is consistent with convention, the caret imparts no information to the user (because it indicates no state that affects the user). StyledText could be made consistent simply by removing the caret when there is a non-empty selection.

The one exception I found to this convention is NotePad v5.1 (besides Eclipse and Netbeans of course). In it, a left to right selection shows the caret at the right edge (but r-l shows no caret). Arrow keys remove the selection and move the caret one space in the arrow direction (as if there were an invisible caret at the left for r-l selection). So it's both unconventional and internally inconsistent. Yuck! Windows Firefox on XP also distinguishes l-r and r-l selection and implements the arrow keys as above, but never shows selection and cursor simultaneously. I can't decide which is worse: a selection state hidden from the user, or a selection plus blinking caret.

In any case, I think it would unequivocally improve StyledText's clarity and consistency by removing the caret when there is a non-empty selection.


Reproducible: Always

Steps to Reproduce:
1. Run Snippet163.
2. Play with selection and l,r arrow keys.
3. Compare with other text editors.
Comment 1 ArronM CLA 2011-02-22 17:39:58 EST
The caret does tell the user some information. It indicates Shift+<arrow key> will do.  

ex. Caret on the right, and SHIFT+LEFT will subtract a character from the selection, and SHIFT+RIGHT will add to the selection.  When the caret is on the left, the opposite affect occurs.  Using a native text widget, there is no indicator of what the key presses will do

IMO, this is an improvement over the native behavior.  Whether this is a bug is up to the Eclipse team, I suppose :)
Comment 2 Doug M CLA 2011-03-04 18:29:10 EST
(In reply to comment #1)
> The caret does tell the user some information. It indicates Shift+<arrow key>
> will do.  
> 
> ex. Caret on the right, and SHIFT+LEFT will subtract a character from the
> selection, and SHIFT+RIGHT will add to the selection.  When the caret is on the
> left, the opposite affect occurs.  Using a native text widget, there is no
> indicator of what the key presses will do
> 
> IMO, this is an improvement over the native behavior.  Whether this is a bug is
> up to the Eclipse team, I suppose :)

That is potentially useful behavior I was not aware of. Contemporary editors I tested use Shift-L & R simply to initially expand the left or right edge of the selection. (You can shrink a chosen side with a more obscure sequence.) With that behavior, the caret adds no information. To make use of the extra functionality provided by the caret, the user would have to anticipate needing to shrink a specific edge while making the initial selection.

While one could argue the odds of that feature being used in practice, I realized my actual interest is in making an application that looks and acts like a platform native one. That's one of the primary design goals of SWT and precisely the reason I chose it over Swing. Even if an alternative selection behavior is subjectively or objectively better, for my users I need SWT text areas to look and act like Mac and Windows text areas. That's the bottom line for this developer.
Comment 3 Lars Vogel CLA 2019-11-08 04:40:08 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.
Comment 4 Doug M CLA 2019-11-08 12:30:12 EST
Dear Lars,

Thank you for responding to the bug report that I filed in 2011, eight years ago. At this point, I have moved on to other interests. The desktop app I was working on in 2012 was a failure, due to numerous bugs in SWT's text handling (many of which could not be worked around), and the glacial responsiveness of SWT's developers to addressing them. 

I can truly say that choosing SWT over Swing for this project was the worst design decision I have ever made in my career. I am sure that SWT is highly tuned to the limited needs of Eclipse, but as a UI for general apps it is unfit for purpose.

Thanks for listening, if anyone is.

Sincerely,
Doug M