Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330857 - [Text] Wrong selection start in IE under some constellation
Summary: [Text] Wrong selection start in IE under some constellation
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.4 M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-22 16:16 EST by DANIEL CLA
Modified: 2011-04-21 03:25 EDT (History)
0 users

See Also:


Attachments
SampleView.java (1.66 KB, application/octet-stream)
2010-11-22 16:18 EST, DANIEL CLA
no flags Details
ActionCopy.java (589 bytes, application/octet-stream)
2010-11-22 16:19 EST, DANIEL CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description DANIEL CLA 2010-11-22 16:16:40 EST
Build Identifier: 20100917-0705

The getSelectionText method of the Text widget mistakenly returns the selected text shifted 2 chars to the right.

 In Mozilla Forefox the getSelectionText method returns the correct text. The problem exists only in IE. 


Reproducible: Always

Steps to Reproduce:
1.Create a view with a single Text widget
2.Write using the append() method a string to the text widget with "\r\n" at the end.
3.Implement right click menu on the text widget with a single action that prints the selected text to the console using text.getSelectionText()

*** Or use the attached files, run the application, select the "test" word in the view, right click, select the Copy action. The output is "st li" instead of "test".
Comment 1 DANIEL CLA 2010-11-22 16:18:48 EST
Created attachment 183607 [details]
SampleView.java
Comment 2 DANIEL CLA 2010-11-22 16:19:45 EST
Created attachment 183608 [details]
ActionCopy.java
Comment 3 Ivan Furnadjiev CLA 2011-04-20 08:18:44 EDT
This is reproducible with Controls Demo too. Tested with IE9.
Comment 4 Ivan Furnadjiev CLA 2011-04-20 08:44:42 EDT
After some investigation I found that the problem is in TextField.js#getSelectionStart(). In case of IE and string ends with "\r\n" the vRange.text.length is two chars shorter. This leads to additional two chars offset in final result: len - vRange.text.length.
Comment 5 Ivan Furnadjiev CLA 2011-04-21 03:25:10 EDT
After searching the web, it seems that this is a known problem in IE (for some reason IE doesn’t always count the \n and \r in the length). Changed TextField.js#getSelectionStart() IE part to proper return the selection start. JS test added. Tested in IE9, IE8 and IE6.