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

Bug 304893

Summary: [Custom Widgets] READ_ONLY CCombo does not de-select text on FocusOut
Product: [Eclipse Project] Platform Reporter: karl.weber99
Component: SWTAssignee: Ian Pun <ipun>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ericwill, ipun, karl.weber99, lshanmug, lufimtse, pinnamur, Silenio_Quarti
Version: 4.8Keywords: triaged
Target Milestone: 4.8 M2   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/100078
https://git.eclipse.org/r/102816
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=a70bf22ca177056eed1efc3b4dc7517117954b95
https://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=9d1e2228537739092cbe86deec0fa218488dd335
Whiteboard:

Description karl.weber99 CLA 2010-03-05 17:18:31 EST
Build Identifier: I20080617-2000

CCombo looks quite ugly if used in eclipse.forms on linux in SWT.READ_ONLY mode. I cannot tell anything about other platforms.

CCombo does always keep its text selected, using text.selectAll(). On my system this leads to a blue background with white text. Even if I select another control, the text in the CCombo stays selected. Text fields usually have white background and black text. The look and feel of CCombo in SWT.READ_ONLY mode does not fit to the look and feel of any form.

I played around a little and found one possible solution: In the constructor one may register the "listener" on CCombo (this) also for the event SWT.FocusOut, i.e. by adding it to comboEvents. If this event occurs, one might simply call text.clearSelection();

I tried it with a copy of CCombo. This solution improves the look and feel a lot, if CCombo is used in a form. The solution I described might not be a decent one, but it should give an impression about what I am talking about. Just try it out.




Reproducible: Always

Steps to Reproduce:
1. Create a form with a CCombo control in SWT.READ_ONLY mode and try it out on a linux box. Or look at the "Product Definition" dialog of the Platform. 
2.
3.
Comment 1 karl.weber99 CLA 2010-03-06 07:15:23 EST
I fooled around a little more with CCombo and got a behaviour that I consider quite decent in eclipse.forms on linux after applying the following changes:

(1) Add the event type SWT.FocusOut to comboEvents in the constructor.

(2) In comboEvent(Event event) add to the switch:

		case SWT.FocusOut:
			text.clearSelection();
			break;

(3) Replace all _unconditional_ text.selectAll() with

if (text.getEditable() && text.isFocusControl()) text.selectAll ();

Note, that there is only one _conditional_ text.selectAll() -- in handleFocus. I left this unchanged.

Nr. (2) is necessary because any Text control does not clearSelection() if it looses the focus. I consider this a bug of the Text control on linux.

Maybe this will help you to improve CCombo on linux.
Comment 2 Eclipse Genie CLA 2017-06-26 17:01:50 EDT
New Gerrit change created: https://git.eclipse.org/r/100078
Comment 3 Ian Pun CLA 2017-06-26 17:04:29 EDT
I've included the fix recommended by karl.weber99@gmx.net. However, this "improvement" should be discussed on why text selection was automatically selected in the first place for READ_ONLY. I'd like a bit of discussion before we decide whether or not to merge it.
Comment 4 Eclipse Genie CLA 2017-08-09 16:53:29 EDT
New Gerrit change created: https://git.eclipse.org/r/102816
Comment 7 Leo Ufimtsev CLA 2017-08-10 12:03:36 EDT
Merged.

@Carolyn, it would be great if you could verify against newest master or against tomorrow's build.
Comment 8 Ian Pun CLA 2017-08-10 13:19:48 EDT
Remove carolyn as she does not work for Eclipse anymore.
Comment 9 Ian Pun CLA 2017-08-18 10:04:33 EDT
changes have been merged. Resolved as fixed.