endDragging
我通过覆盖DialogBox 的方法找到了我正在寻找的解决方案。这里是:
@Override
protected void endDragging(MouseUpEvent event)
{
//Move dialog window behind top border
if(this.getAbsoluteTop() < 0) {
this.setPopupPosition(this.getPopupLeft(), 0);
}
//Move dialog window behind bottom border
if(this.getAbsoluteTop() > (Window.getClientHeight() - this.getOffsetHeight())) {
this.setPopupPosition(this.getPopupLeft(), Window.getClientHeight() - this.getOffsetHeight());
}
//Move dialog window behind left border
if(this.getAbsoluteLeft() < 0) {
this.setPopupPosition(0, this.getPopupTop());
}
//Move dialog window behind right border
if(this.getAbsoluteLeft() > (Window.getClientWidth() - this.getOffsetWidth())) {
this.setPopupPosition(Window.getClientWidth() - this.getOffsetWidth(), this.getPopupTop());
}
super.endDragging(event);
}
当对话框从屏幕上移开时,它会在鼠标释放后出现在屏幕的可见部分。可以对其进行改进和覆盖continueDragging
,以防止窗口完全移出屏幕。