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

Bug 404615

Summary: [ClientScripting][Text] setSelection and getSelection do not work correctly in Modify event
Product: [RT] RAP Reporter: Tim Buschtoens <tbuschto>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tbuschto
Version: 2.1   
Target Milestone: 2.1 M2   
Hardware: All   
OS: All   
Whiteboard:

Description Tim Buschtoens CLA 2013-03-29 10:16:30 EDT
The follwing does not work in a Modify client event:

      widget.setText( "foo" );
      widget.setSelection( [ 1, 2 ] );

But this does:

      widget.setText( "foo" );
      window.setTimeout( function() { 
        widget.setSelection( [ 1, 2 ] );
      }, 0 );

In SWT it works.
Comment 1 Tim Buschtoens CLA 2013-03-29 10:50:27 EDT
The values of getSelection within a Modify event may also be incorrect. They are sometimes off by one, especially when starting to write in an empty field, or when using backspace.
Comment 2 Tim Buschtoens CLA 2013-04-02 05:23:15 EDT
Even eith the setTimeout workaround the actually rendered selection is sometimes off by one.
Comment 3 Tim Buschtoens CLA 2013-04-03 05:07:29 EDT
The getter issue is webkit only.
Comment 4 Tim Buschtoens CLA 2013-04-04 10:17:26 EDT
Fixed with commit 240d12ef886c3f6bebdc0205dbf0ce3475b06562 (RAP repository).

Change event is now fired with a delay so the selection values on the
input element are already updated. This also seems to fix the issue with setSelection.