Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shift Key in GWT?

Tags:

gwt

Is there a way in GWT to tell if the Shift key is down inside of an onClick() handler?

For example:

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;

public class PanelTileBase implements ClickHandler {

    PanelTileBase()
    {
        addClickHandler(this);
    }

    public void onClick(ClickEvent event)
    {
        // is the shift key down?
    }
}

Thanks!

like image 521
Soren Johnson Avatar asked Sep 11 '09 15:09

Soren Johnson


2 Answers

How about this (untested)

void onClick(ClickEvent ev) {
  NativeEvent nEv = ev.getNativeEvent(); 
  if ( nEv.getShiftKey() ) { 
    // event is true.
  }
}
like image 138
Chris K Avatar answered Nov 15 '22 09:11

Chris K


And for the keyboard API changed, but the idea is the same:

if (event.isShiftKeyDown()) {
    // your code                
}
like image 25
Flueras Bogdan Avatar answered Nov 15 '22 09:11

Flueras Bogdan