Question

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!

Was it helpful?

Solution

How about this (untested)

void onClick(ClickEvent ev) {
  NativeEvent nEv = ev.getNativeEvent(); 
  if ( nEv.getShiftKey() ) { 
    // event is true.
  }
}

OTHER TIPS

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

if (event.isShiftKeyDown()) {
    // your code                
}

GWT KeyEvent API has the is{Alt,AnyModifier,Control,Meta,Shift}KeyDown() functions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top