Charmin
Charmin

Reputation: 711

Notice every click in a gwt application

I'm working on a automatic logout class. After x minutes without actions I want to log out the user. Everything is working, but I need a point in my application where to reset my timer.

I want to reset the timer with every click in my application. Is there a way to notice every click an throw an event? Maybe a LayeredPanel or GlassPanel?

I don't like the idea of resetting the timer by moving the mouse.

Upvotes: 2

Views: 144

Answers (1)

El Hoss
El Hoss

Reputation: 3832

You can add some code to your EntryPoint:

Event.addNativePreviewHandler(new NativePreviewHandler() { 
  @Override 
  public void onPreviewNativeEvent(NativePreviewEvent event) {
    if (event.getNativeEvent().getType().equals("click")) { 
      // reset your timer
    } 
  }
});

In case the user clicks in your app, you'll get the chance to do something.

Upvotes: 4

Related Questions