Home » Eclipse Projects » Remote Application Platform (RAP) » Text's keyReleased listener doesn't deliver complete Text.getText().
Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062571] |
Sun, 09 June 2013 08:57 |
somporn pongpan Messages: 7 Registered: April 2013 |
Junior Member |
|
|
I found a likely bug with RAP 2.1 RC2-RC3 regarding Text's keyReleased listener and this doesn't happen on RAP 2.0 RC3. This problem happens on IE10, Chrom 27.0.1453.110 m and Firefox 21.0 -- all in their latest versions.
On the server side, I add keyRelease KeyListner to Text component shown below.
Text filterText = new Text(composite, SWT.BORDER);
filterText.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
System.out.println(filterText.getText());
}
});
On my page every time that I type a character on filterText textfield, RAP will deliver that character and called keyReleased method. However, when I print filterText.getText() to the console, a delivered character isn't included in Text.getText().
For example:
First time I type '1', Text.getText() printed nothing.
Sencond time I type '2', Text.getText() printed '1'.
Third time I type '3', Text.getText() printed '12'.
Fourth time I type '4', Text.getText() printed '123'.
If I look at sending json string on the Firefox Firebug console, it is clear to me that the javascript side engine doens't deliver all its complete value so I think there is something wrong on the Javascript side.
Note again that this problem doesn't happen on RAP 2.0 RC3.
|
|
|
Re: Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062573 is a reply to message #1062571] |
Sun, 09 June 2013 09:21 |
somporn pongpan Messages: 7 Registered: April 2013 |
Junior Member |
|
|
After spent some time digging into RAP Javascript code, I found the likely wrong in bundles\org.eclipse.rap.rwt\js\rwt\widgets\base\BasicText.js:643 (RAP 2.1 RC3):
633:
634: _oninput : function() {
635: try {
636: var newValue = this.getComputedValue().toString();
var doit = true;
if( this.hasEventListeners( "input" ) ) {
doit = this.dispatchEvent( new rwt.event.DataEvent( "input", this._typed ), true );
}
641: if( doit ) {
642: // at least webkit does sometiems fire "input" before the selection is updated
643: rwt.client.Timer.once( this._updateValueProperty, this, 0 );
644: } else if( rwt.client.Client.isWebkit() || rwt.client.Client.isMshtml() ){
645: // some browser set new selection after input event, ignoring all changes before that
rwt.client.Timer.once( this._renderSelection, this, 0 );
this._selectionNeedsUpdate = true;
}
} catch( ex ) {
rwt.runtime.ErrorHandler.processJavaScriptError( ex );
}
},
654: _updateValueProperty : function() {
655: this.setValue( this.getComputedValue().toString() );
656: },
657:
It looks like rwt.client.Timer.once() on line 643 cannot set the complete value to Json string on the time that Ajax request has been called.
Compare to BasicText.js on RAP 2.0 RC3 below which on the line 642:
634: _oninput : function() {
try {
var newValue = this.getComputedValue().toString();
var doit = true;
if( this.hasEventListeners( "input" ) ) {
doit = this.dispatchEvent( new rwt.event.DataEvent( "input", this._typed ), true );
}
if( doit ) {
642: this.setValue( newValue ); // if doit is false, the listener has to do this
} else if( rwt.client.Client.isWebkit() || rwt.client.Client.isMshtml() ){
// some browser set new selection after input event, ignoring all changes before that
rwt.client.Timer.once( this._renderSelection, this, 0 );
this._selectionNeedsUpdate = true;
}
} catch( ex ) {
rwt.runtime.ErrorHandler.processJavaScriptError( ex );
}
651: },
The code on RAP 2.0 RC3 didn't call a Timer class and it didn't has this problem.
[Updated on: Sun, 09 June 2013 09:22] Report message to a moderator
|
|
|
Re: Text's keyReleased listener doesn't deliver complete Text.getText(). [message #1062575 is a reply to message #1062573] |
Sun, 09 June 2013 09:37 |
Ivan Furnadjiev Messages: 2427 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi,
please open a bugzilla about this regression and put your findings there.
Thanks,
Ivan
On 6/9/2013 12:21 PM, somporn pongpan wrote:
> After spent some time digging into RAP Javascript code, I found the
> likely wrong in
> bundles\org.eclipse.rap.rwt\js\rwt\widgets\base\BasicText.js:643 (RAP
> 2.1 RC3):
>
>
> 633:
> 634: _oninput : function() {
> 635: try {
> 636: var newValue = this.getComputedValue().toString();
> var doit = true;
> if( this.hasEventListeners( "input" ) ) {
> doit = this.dispatchEvent( new rwt.event.DataEvent( "input",
> this._typed ), true );
> }
> 641: if( doit ) {
> 642: // at least webkit does sometiems fire "input" before
> the selection is updated
> 643: rwt.client.Timer.once( this._updateValueProperty, this,
> 0 );
> 644: } else if( rwt.client.Client.isWebkit() ||
> rwt.client.Client.isMshtml() ){
> 645: // some browser set new selection after input event,
> ignoring all changes before that
> rwt.client.Timer.once( this._renderSelection, this, 0 );
> this._selectionNeedsUpdate = true;
> }
> } catch( ex ) {
> rwt.runtime.ErrorHandler.processJavaScriptError( ex );
> }
> },
>
> 654: _updateValueProperty : function() {
> 655: this.setValue( this.getComputedValue().toString() );
> 656: },
> 657:
>
>
> It looks like rwt.client.Timer.once() on line 643 cannot set the
> complete value to Json string on the time that Ajax request has been
> called.
>
> Compare to BasicText.js on RAP 2.0 RC3 below which on the line 642:
>
>
> 643: _oninput : function() {
> try {
> var newValue = this.getComputedValue().toString();
> var doit = true;
> if( this.hasEventListeners( "input" ) ) {
> doit = this.dispatchEvent( new rwt.event.DataEvent( "input",
> this._typed ), true );
> }
> if( doit ) {
> 642: this.setValue( newValue ); // if doit is false, the
> listener has to do this
> } else if( rwt.client.Client.isWebkit() ||
> rwt.client.Client.isMshtml() ){
> // some browser set new selection after input event, ignoring
> all changes before that
> rwt.client.Timer.once( this._renderSelection, this, 0 );
> this._selectionNeedsUpdate = true;
> }
> } catch( ex ) {
> rwt.runtime.ErrorHandler.processJavaScriptError( ex );
> }
> 651: },
>
>
> The code on RAP 2.0 RC3 didn't call a Timer class and it didn't has
> this problem.
--
Ivan Furnadjiev
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
| |
Goto Forum:
Current Time: Sat Sep 21 03:12:03 GMT 2024
Powered by FUDForum. Page generated in 0.03179 seconds
|