NativeEvent Get Type Issue

74 views
Skip to first unread message

Salman Hemani

unread,
Jan 6, 2010, 4:21:12 PM1/6/10
to Google Web Toolkit
This is a good one. Totally confused. I am porting over an application
from GWT 1.5 - 1.7 (I still have to upgrade to 2.0 but that will come
at a later stage. The onEventPreview used to block the escape key.
When I ported over to the NativePreviewHandler things ofcourse
changed. Before I even get to checking the escape key I was fiddling
around with the nativeEvent itself and I am running into something
wierd. Here is the code:

public void onPreviewNativeEvent(final NativePreviewEvent
nativePreviewEvent) {

final NativeEvent nativeEvent =
nativePreviewEvent.getNativeEvent();

DeferredCommand.addCommand(new Command() {

public void execute() {

System.out.println(nativeEvent.getType());

}
});

It spits out an error at nativeEvent.getType() which is as follows:


[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (Error): Member not
found.

number: -2147352573
description: Member not found.

at com.google.gwt.dom.client.DOMImpl.eventGetType(Native Method)
at com.google.gwt.dom.client.NativeEvent$.getType$(NativeEvent.java:
209)
at com.christiedigital.widgets.core.popup.BasePopupPanel$1.execute
(BasePopupPanel.java:83)
at com.google.gwt.user.client.CommandExecutor.doExecuteCommands
(CommandExecutor.java:310)
at com.google.gwt.user.client.CommandExecutor$2.run
(CommandExecutor.java:205)
at com.google.gwt.user.client.Timer.fireImpl(Timer.java:160)
at com.google.gwt.user.client.Timer.fireAndCatch(Timer.java:146)
at com.google.gwt.user.client.Timer.fire(Timer.java:138)


Any insights?

Thomas Broyer

unread,
Jan 7, 2010, 4:35:09 AM1/7/10
to Google Web Toolkit

The events cannot be used "async"; you must retrieve all the
properties upfront before doing your DeferredCommand:

public void onPreviewNativeEvent(NativePreviewEvent
nativePreviewEvent) {
NativeEvent nativeEvent =
nativePreviewEvent.getNativeEvent();
final String eventType = nativeEvent.getType();


DeferredCommand.addCommand(new Command() {
public void execute() {

System.out.println(eventType);
}
});

Salman Hemani

unread,
Jan 7, 2010, 1:39:22 PM1/7/10
to Google Web Toolkit
Hi Thomas,

Thanks for your response. The only reason I have the DeferredCommand
in there is to actually spit this out. If I don't defer it, my
application simply freezes as its spiting out this error as I move my
mouse around. So essentially I don't even see the println since this
preview occurs and crashes. My point is that the error still occurs
regardless.

Any other thoughts?
Thanks

>         });- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages