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

Bug 312215

Summary: [Text] Text widget with default message needs a second click (IE)
Product: [RT] RAP Reporter: Niels Lippke <niels.lippke>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.3   
Target Milestone: 1.3 RC1   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Niels Lippke CLA 2010-05-10 04:14:39 EDT
When using a text widget with a default message, the text field does not 
handle the focus correctly: The message disappears, but there's no cursor 
and you also cannot type in any text. You have to click a second time upon 
the text field to get the cursor.
This seems to be an IE (8) issue, since I it works on FF.

Sample snippet:
public void createPartControl(Composite parent) {
parent.setLayout(new RowLayout());
Text text = new Text(parent, SWT.BORDER);
text.setMessage("enter");
}
Comment 1 Ivan Furnadjiev CLA 2010-05-12 04:56:19 EDT
IE8, Safari 4.05 and Opera 10.53 have this problem, Chrome 5.0.396 and FF 3.6.3 work fine.
Comment 2 Ivan Furnadjiev CLA 2010-05-12 08:35:06 EDT
Created attachment 168129 [details]
Proposed patch

This patch provides a workaround for the problem. It initializes buffered selectionStart and selectionLenght with zero. Thus, the first time focusing is forced by selection and the selection is set to 0, 0. In addition, this makes all browsers to have the same value returned by TextFiled#getSelectionStart - 0, instead -1 in IE, null in FF.
Comment 3 RĂ¼diger Herrmann CLA 2010-05-12 08:45:48 EDT
The patch looks good, please go ahead and commit it.
Comment 4 Ivan Furnadjiev CLA 2010-05-12 09:21:21 EDT
Applied patch to CVS HEAD.