Friday, January 27, 2017

Re: How to simulate a click for a GWT button using fireEvent

I have use this.

this.getComo().addKeyPressHandler(new KeyPressHandler() {
            public void onKeyPress(KeyPressEvent event) {
                int teclado = event.getNativeEvent().getKeyCode();
                if ((teclado == KeyCodes.KEY_ENTER)) {
                    getEntrar().fireEvent(new GwtEvent<ClickHandler>() {
                        protected void dispatch(ClickHandler handler) {

                        public<ClickHandler> getAssociatedType() {
                            return ClickEvent.getType();


Em 26/01/2017 16:59, Privat escreveu:

I am trying to simulate a mouse click event on GWT (Google Web Toolkit) Application in <=IE8 (using fireEvent, not dispatchEvent)

A sample custom button can be found here:!CwCustomButton (The toggle button is easiest to see if the click was processed)

The major boilerplate for simulating the click can be found here: (This is where I got the simulate function used below)

I have been able to successfully simulate the click event by using the following commands for IE9+ (in this case simulate used dispatchEvent)

simulate(document.getElementById("gwt-debug-cwCustomButton-toggle-normal"), "mouseover");  simulate(document.getElementById("gwt-debug-cwCustomButton-toggle-normal"), "mousedown");  simulate(document.getElementById("gwt-debug-cwCustomButton-toggle-normal"), "mouseup");    

In my application the fireEvent fails, because GWT's $wnd.event is null. (Line: 117,

If there is no way to simulate the click with plain JS, then is there a way to use GWT's EventDispatcher to simulate the click?

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment