| 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 |
Sign in to add a comment
|
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:
|
||||||||||||||||
,
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 |
|||||||||||||||||
,
Jul 03, 2007
(No comment was entered for this change.)
Status: Accepted
|
|||||||||||||||||
,
Jul 03, 2007
(No comment was entered for this change.)
Status: Started
|
|||||||||||||||||
,
Jul 10, 2007
Fix committed as r1229.
Status: FixedNotReleased
|
|||||||||||||||||
,
Aug 20, 2007
1.4 RC2 now released.
Status: Fixed
|
|||||||||||||||||
|
,
Apr 28, 2008
Owner: jgw
|
|||||||||||||||||
|
,
Apr 29, 2008
|
|||||||||||||||||
|
,
Apr 29, 2008
|
|||||||||||||||||
|
,
Apr 29, 2008
Cc: -gwt.team.knorton knor...@google.com
|
|||||||||||||||||
|
|
|||||||||||||||||