Friday, September 12, 2014

DialogBox sized inside out with scrollpanel trick/tip/workaround

Hi,

First of all I am aware of
https://code.google.com/p/google-web-toolkit/issues/detail?id=889

I think I have a different problem and I would like to ask if this is expected behavior.

I have the following layout DialogBox/ScrollPanel/CellTable

I want the DialogBox to be size inside-out - meaning to take its size from the CellTable.

This is not working as I am getting wrong (zero?) widths and heights in my callback. However it works perfectly in Chrome and Firefox (don't know about IE) if I call the callback from a deferred command.

Now if you get a little more creative you can set the size of the scrollpanel during the setPosition() so you can avoid toggling scrollbars on the main window or getting out of the screen anyway.

--------------
    @Override
    public void setPopupPositionAndShow() {
        setVisible(false);
        super.show();
        // we want to avoid jumping effects
        setVisible(false);
        Scheduler.get().scheduleDeferred(new ScheduledCommand() {
            @Override
            public void execute() {
                callback.setPosition(getOffsetWidth(), getOffsetHeight());
                setVisible(true);
            }
        });
    }

-------- found in original PopupPanel (ancestor of DialogBox)

    public void setPopupPositionAndShow(PositionCallback callback) {
        setVisible(false);
        show();
        callback.setPosition(getOffsetWidth(), getOffsetHeight());
        setVisible(true);
    }
-----------------

So is this normal? The documentation seems to expect that kind of behavior without the need of the extra deferring command.

--
Vassilis Virvilis

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment