fireNativeEvent it deprecated, so don't use it.

I've heard of a very dirty hack that uses native code to skip past the
private-ness of the Gwt Event system, but it is too much of a hack to
promote anywhere.

Better yet, rather than trying to fire an event with some kind of
synthetic event, you would be much better to externalize the logic you
want to fire on an event as well as programmatically.   Even if you
could easily fire a synthetic event, you wouldn't be able to access
native event methods like getClientX() getKeyCode(), only the getSource
() method is of interest, and it has had it's type erased to Object
{you can safely cast back to Widget on normal events}...

If you're trying to port 1.5 code, you'll have

public void onClick(Widget w) { ... }

In 1.6, you get:

public void onClick(ClickEvent e) { ... }

To port, include your 1.5 onClick {don't bother Overriding
ClickListener, just leave the interface out}:

public void onClick(ClickEvent e) {
onClick((Widget)e.getSource());
 }

And then you'll have two methods, and you can still get your
programmatic access.

If you need variables like ClientX and ClientY, externalize those
too...

private int left,top;

public void onClick(ClickEvent e) {
left=e.getNativeEvent().getClientX();
top=e.getNativeEvent().getClientY();
onClick((Widget)e.getSource());
 }

public void synthClick(Widget src,int x, int y){
left=x;top=y;onClick(src);
}
public void onClick(Widget x){
x.getElement.getStyle().setProperty("left",left);
}

...You can't CREATE an event in javascript, so there's no reason why
GWT should pretend like you can.  If you really want, you could make a
SynthClickEvent, SynthClickType and SynthClickHandler, but I'm pretty
sure that's more work than just externalizing your event handling
methods...

If this won't work, post some detailed source...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to