I have a GWT widget that is a Window. The user can drag/drop the Window. I am using an old API called GWT-Ext. It has the ability to implement a listener to detect when the Window has been moved. I want to prevent the Window from being hidden under the browser bar by detecting the XY coordinates of the Window and putting the Window back to the original location if it goes "out of bounds". How can I determine the XY coordinate of the browser bar so I know if my Window is obscured by the browser bar or not?

有帮助吗?

解决方案 2

I determined that the browser bar was located at 0. So I check if my Y position is less than 0 then call .setPagePosition.

this.addListener(new PanelListenerAdapter()
{
   @Override
   public void onMove(BoxComponent component, int x, int y)
   {
      // prevent user from accidentally dragging window under browser bar
      if (y <= 0)
      {
         component.setPagePosition(DEFAULT_X_POS, DEFAULT_Y_POS);
      }
   }            
});

其他提示

The browser bar is always at 0. You have to account for the scroll position of the document though, so in effect it's at Document.get().getScrollTop().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top