Bug 484470 - [Combo] Text selection issue on focusIn event
Summary: [Combo] Text selection issue on focusIn event
Status: ASSIGNED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 3.1   Edit
Hardware: All Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-16 05:02 EST by Tim Nielens CLA
Modified: 2016-01-04 05:37 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Nielens CLA 2015-12-16 05:02:24 EST
Browser : Firefox 42.0
Snippet : 

public class BasicEntryPoint extends AbstractEntryPoint implements Listener{
	private String[] content = new String []{"Bonjour", "Hello", "Gueten Tag", "Goeiedag"};
	private Combo combo;
	@Override
	protected void createContents(Composite parent) {
		parent.setLayout(new GridLayout(1, false));
		combo = new Combo(parent, SWT.BORDER);
		combo.setItems(content);
		combo.select(0);
		combo.addListener(SWT.FocusIn, this);
	}
	@Override
	public void handleEvent(Event event) {
		Point selection = combo.getSelection();
		System.out.println(selection);
//		if (selection.x != 0 || selection.y != combo.getText().length()){
//			combo.setSelection(new Point(0,combo.getText().length()));
//		}
	}
}

Scenario 1 :
- Focus In the combo 
- Select the full text 
- Focus out
- Click on the text in the combo and focus in again
Result : 
On the second focus in event, the text quickly flashes as fully selected, but the text is, in the end, unselected with the cursor set at the mouse click position. This differs from RCP behaviour (text is selected). This is also incoherent with the selection value (put a break point in the handle event method and inspect the selection value).

Scenario 2 : 
- Focus In the combo 
- Select the full text 
- Focus out
- Click in the tiny space between the combo border and the text selection area. 
Result : 
Text is fully selected.
Comment 1 Ivan Furnadjiev CLA 2015-12-17 07:08:38 EST
That's how browser native input field works - selection is removed when you click (set caret position) on it. I don't think that we can do anything about it.
Comment 2 Tim Nielens CLA 2015-12-17 10:47:50 EST
The problem is that the widget on server side does not reflect the selection state in the browser. 
Try to set the full selection on the focusIn event (uncomment the three lines).