0

I have this code which fires even if I don't click on anything on the page, just hovering over the page this will trigger:

Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
            @Override
            public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
                switch (event.getTypeInt()) {
                    case Event.ONCLICK:
                        $(".hopscotch-bubble").fadeOut(new com.google.gwt.query.client.Function() {
                            @Override
                            public void f() {
                                JSNIHelper.infoNotify("INFO", "Fade out method invoked!");
                            }
                        });

                }
            }
        });

I am not entirely sure why this happens, what could be the reason?

quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

0

Add the ClickHandler on the Root Panel itself that will be called when a native click event is fired anywhere on the page.

Sample code:

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.RootPanel;

RootPanel.get().addDomHandler(new ClickHandler() {
    
    @Override
    public void onClick(ClickEvent event) {
        System.out.println("Click");
        
    }
}, ClickEvent.getType());
Community
  • 1
  • 1
Braj
  • 46,415
  • 5
  • 60
  • 76