My favorites | Sign in
Google
                
New issue | Search
for
| Advanced search | Search tips
Issue 1243: REGRESSION: PopupPanel.getOffsetWidth() and getOffsetHeight() return 0 when called inside onLoad() method
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  jgw+personal@google.com
Closed:  Aug 2007
Cc:  knorton@google.com
Type-Defect
Priority-Critical
Category-UI
Milestone-1_4_RC2


Sign in to add a comment
 
Reported by mpedzi...@stuart.iit.edu, Jun 13, 2007
Found in GWT Release: GWT1.4

Detailed description:

Doing the following to position a popup panel in the correct position 
relative to the browser window in GWT1.4.
int x = 0, SOMEPOSX = SOMEPOSY;
 public void onLoad() {
            super.onLoad();
                    if (x + (2*getOffsetWidth()) > Window.getClientWidth
()) {
                        x = Window.getClientWidth() - (2 *getOffsetWidth
());
                    }
                    if (y + (2*getOffsetHeight()) > Window.getClientHeight
()) {
                        y = Window.getClientHeight() - (2*getOffsetHeight
());
                    }
                    setPopupPosition(x, y);
               
        }

This is because getOffsetX() methods return 0 when called from inside the 
onload() method. In GWT1.3 and prior releases, these methods returned the 
actual size of the panel but has become broken in GWT1.4 

Workaround if you have one:
Use DeferredCommand.addCommand() thus:

public void onLoad() {
            super.onLoad();
            DeferredCommand.addCommand(new Command() {
                public void execute() {
                    if (x + (2*getOffsetWidth()) > Window.getClientWidth
()) {
                        x = Window.getClientWidth() - (2 *getOffsetWidth
());
                    }
                    if (y + (2*getOffsetHeight()) > Window.getClientHeight
()) {
                        y = Window.getClientHeight() - (2*getOffsetHeight
());
                    }
                    setPopupPosition(x, y);
                }
            });
        }

Links to the relevant GWT Developer Forum posts:

Comment 1 by gwt.team.morrildl, Jun 27, 2007
(No comment was entered for this change.)
Summary: REGRESSION: PopupPanel.getOffsetWidth() and getOffsetHeight() return 0 when called inside onLoad() method
Owner: gwt.team.jgw
Cc: gwt.team.knorton
Labels: -Priority-Medium Priority-Critical Category-UI Milestone-1_4_RC2
Comment 2 by gwt.team.jgw, Jul 03, 2007
(No comment was entered for this change.)
Status: Accepted
Comment 3 by gwt.team.jgw, Jul 03, 2007
(No comment was entered for this change.)
Status: Started
Comment 4 by gwt.team.jgw, Jul 10, 2007
Fix committed as r1229.
Status: FixedNotReleased
Comment 5 by gwt.team.scottb, Aug 20, 2007
1.4 RC2 now released.
Status: Fixed
Comment 6 by sumitcha...@google.com, Apr 28, 2008
 
Owner: jgw
Comment 7 by knorton@google.com, Apr 29, 2008
 
Comment 8 by knorton@google.com, Apr 29, 2008
 
Comment 9 by knorton@google.com, Apr 29, 2008
 
Cc: -gwt.team.knorton knor...@google.com
Sign in to add a comment