1

I tried to implement ProvidesResize interface to com.google.gwt.user.client.ui.AbsolutePanel. Then I implemented RequiresResize to its supposed childs but it seems like method onResize() fails to be called or I didn't get it :(

So my question is... How to catch was an AbsolutePanel child widget resized or not and is it possible to?

P.S. GWT 2.2/2.3

4

3 回答 3

2

Your panel itself could implement the RequiresResize interface and have the onResize() method do something like this (copied from DeckLayoutPanel):

  public void onResize() {
    for (Widget child : getChildren()) {
      if (child instanceof RequiresResize) {
        ((RequiresResize) child).onResize();
      }
    }
  }

Now if you make your panel a child of a ProvidesResize widget, the chain of onResize() calls should propagate through your panel to the children of your panel.

于 2013-02-06T17:40:00.363 回答
1

HTML just doesn't tell you when something changes size. Major bummer.

What you CAN find out is when the window changes size. RootLayoutPanel listens for window size change events. When it hears one, it tells all its children, "Hey, you probably just changed size. Check it out." Then all of those children are supposed to tell all of THEIR children, "Hey, check your size, guys. Might be different."

So. Your AbsolutePanel that implements ProvidesResize has to be hooked into this process somehow. If you add it to RootLayoutPanel, you can get the message by also implementing RequiresResize. If you're not adding it into the RootLayoutPanel chain, you have to find out resize information yourself somehow. You could either listen for window size events, or trigger the size calculation when you know something else changed in the layout. Whatever you want. Unfortunately this can't be done for you unless you have a continuous chain of RequiresResize and ProvidesResize widgets all the way up to RootLayoutPanel.

于 2013-02-06T21:24:28.153 回答
1

You can do something simillar to this

于 2013-02-07T03:00:16.587 回答