Great! Worked perfectly thank you. Yeah I will look at filing a bug report.
On Nov 30, 9:37 pm, Thomas Broyer <[email protected]> wrote: > On Nov 26, 1:59 am, David T <[email protected]> wrote: > > > > > > > Hi All, > > > I'm trying to use the provided PopupPanel.center() method tocentera > > popup panel on the screen. This works fine on Opera and Safari > > centering the popup relative to the browser window. In Firefox though > > it centers the popup relative to the entire page. > > > I've tried to implement my owncentermethod as follows: > > > private voidcenter() { > > popup.setPopupPositionAndShow(new PositionCallback() { > > > public void setPosition(int offsetWidth, int offsetHeight) > > { > > int[] winSize = windowSize(); > > int left = (winSize[0] - offsetWidth) >> 1; > > int top = (winSize[1] - offsetHeight) >> 1; > > popup.setPopupPosition(Window.getScrollLeft() + > > left, > > Window.getScrollTop() + top); > > } > > > }); > > > } > > > public final native int[] windowSize() /*-{ > > var myWidth = 0, myHeight = 0; > > if (typeof(window.innerWidth) == 'number') { > > //Non-IE > > myWidth = window.innerWidth; > > myHeight = window.innerHeight; > > } else if (document.documentElement && > > (document.documentElement.clientWidth || > > document.documentElement.clientHeight)) { > > //IE 6+ in 'standards compliant mode' > > myWidth = document.documentElement.clientWidth; > > myHeight = document.documentElement.clientHeight; > > } else if (document.body && (document.body.clientWidth || > > document.body.clientHeight)) { > > //IE 4 compatible > > myWidth = document.body.clientWidth; > > myHeight = document.body.clientHeight; > > } > > return [myWidth, myHeight]; > > > }-*/; > > > But this doesn't work as the windowSize() method returns 0 for reasons > > I don't know. > > You use 'window' and 'document', which refer to the hidden iframe's > window and document your GWT code is loaded in (your > <permutation>.cache.html). You should always use $wnd and $doc in JSNI > code. > > (and I agree PopupPanel.center() should use window.innerHeight/Width > where possible; at least when the document is smaller than the window; > have you filed a bug?) -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
