Shift Key in GWT?

随声附和 提交于 2019-12-23 09:35:08

问题


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!


回答1:


How about this (untested)

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



回答2:


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

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



回答3:


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



来源:https://stackoverflow.com/questions/1411752/shift-key-in-gwt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!