haojianyun / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 1 forks source link

Exception in KeyPressEvent.getCharacterValue() #134

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The method "public native int KeyPressEvent.getCharacterValue()" causes an
"Expected primitive type int; actual value was undefined" exception when
the user presses a non-character key like shift, alt, backspace etc. For
those keys, jsObj.characterValue is "undefined", and converting it to "int"
is not possible.

Could you change the method return type from "int" to "Integer"? That way,
the method returns "null" if jsObj.characterValue is undefined, and that's
something the onKeyPress event handler code can deal with.

Tested with latest SVN / Gwt 1.5.3 in Windows hosted mode.

Thanks

Original issue reported on code.google.com by Hartmut....@gmail.com on 27 Feb 2009 at 3:54

GoogleCodeExporter commented 9 years ago
Ah, sh#!** - GWT doesn't do autoboxing, so changing the return type from "int" 
to
"Integer" causes the method to fail for all proper integer values with
"IllegalArgumentException: Something other than a Java object was returned from 
JSNI
method"

Maybe keep the return type "int" and return -1 if jsObj.characterValue is 
undefined?

Original comment by Hartmut....@gmail.com on 27 Feb 2009 at 4:08

GoogleCodeExporter commented 9 years ago
Here's a patch that fixes this. I've changed the return type from int to 
Integer, and
I call your helper function JSOHelper.toInteger() to box the character value. 
If the
value is undefined, the function returns null

Original comment by Hartmut....@gmail.com on 4 Mar 2009 at 3:52

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by sanjiv.j...@gmail.com on 4 Mar 2009 at 4:18

GoogleCodeExporter commented 9 years ago
Fixed in SVN, thanks.

Original comment by sanjiv.j...@gmail.com on 9 Mar 2009 at 1:03