我正在使用 GWT,并且想要在用户将鼠标左键按住 GWT 按钮时执行操作。但我找不到合适的事件处理程序或解决该问题的其他解决方案。
GWT 中是否有一种方法可以单击按钮,按住鼠标按钮并一次又一次地执行相同的操作,直到释放鼠标按钮?
Button scrollUpBtn = new Button("Top");
scrollUpBtn.setWidth("66px");
scrollUpBtn.addMouseDownHandler(new MouseDownHandler() {
@Override
public void onMouseDown(MouseDownEvent event) {
//handCards.setVerticalScrollPosition(handCards.getVerticalScrollPosition() - 10);
mouseUp = true;
}
});
scrollUpBtn.addMouseUpHandler(new MouseUpHandler() {
@Override
public void onMouseUp(MouseUpEvent event) {
mouseUp = false;
}
});
scrollUpBtn.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (mouseUp == true) {
handCards.setVerticalScrollPosition(handCards.getVerticalScrollPosition() - 10);
}
}
});