I have a canonical ("extends Composite") GWT 2.5.1/UiBinder app. There are
three horizontal sections on the browser page, comprised of div elements;
let's call them top, middle, and bottom. The layout is fluid/dynamic with
respect to the browser's window size. I have Java code that vertically
centers the middle section in the space between the top and bottom
sections; I do this at startup, and also on a browser resize event, by
calling this method:
protected void positionMiddle() {
> int topOfSpace = topSection.getAbsoluteBottom();
> int botOfSpace = botSection.getAbsoluteTop();
> int middleHeight = middleSection.getClientHeight();
> int topOfMiddle = topOfSpace + (botOfSpace - topOfSpace -
> middleHeight)/2;
> DOM.setStyleAttribute(DOM.getElementById("midSection"), "top",
> topOfBoard + "px");
> }
>
If startup call is done in my app/widget's constructor, or if it is done in
an onLoad() method, it doesn't work correctly because getAbsoluteBottom,
getAbsoluteTop, and getClientHeight all return 0. What I have done is wait
until the first user interaction, which must be a button click to dismiss a
splash screen, to call the above method; that works fine. I reason that the
method call must be delayed until the browser has finished its rendering,
i.e., finished its layout computations. I am wondering whether there is
some way, such as an event I could detect via a handler, to know when that
is. While having the first call to positionMiddle() in a button click
handler works OK, it seems inelegant. Also, I'd like to better understand
the relation between GWT and browser rendering at startup.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.