Tuesday, December 27, 2011

Help with resizing

I can't get onResize() to be called on some of my panels. I'm using
Activities and Places. The top level panel is a DockLayoutPanel. All
of the activity happens in the center panel. The view I'm having
trouble with looks like this.

public class MyViewImpl extends ResizeComposite implements MyView,
RequiresResize, ProvidesResize
{
interface Binder extends UiBinder<Widget, MyViewImpl>
{
}

private static final Binder binder = GWT.create( Binder.class );
@UiField SplitLayoutPanel splitPanel; // The SplitPanel
@UiField FlowPanel westArea; // FlowPanel in
SplitLayoutPanel's west area
@UiField TabLayoutPanel centerArea; // Tab panel is
SplitLayoutPanel's center area
@UiField FormPanel tab1Panel; // Tab 1
@UiField FormPanel tab2Panel; // Tab 2
@UiField HorizontalPanel tab3Panel; // Tab 3

...

public void onResize()
{
// This gets called.
}
}

MyViewImpl contains a top level SplitLayoutPanel that contains two
areas. The west area is a FlowPanel and the center area contains a
TabLayoutPanel. The TabLayoutPanel contains three tabs. The third
tab contains a list of image tiles and the layout is adjusted upon
resize (which I can't get to fire).

When a resize occurs, the MyViewImple receives the onResize(). I
can't get the SplitLayoutPanel to receive the events though.
Ultimately I want the resize events to propogate to the TabLayoutPanel
so the third tab can layout the image tiles based on its dimensions.

I've tried to add a resize handler to the SplitLayoutPanel like this,
but it doesn't get called.

public MyViewImpl()
{
initWidget( binder.createAndBindUi( this ) );

ResizeHandler h = new ResizeHandler(){
public void onResize( ResizeEvent ev )
{
log.info( "Got Resize in splitter" );
}
};
splitPanel.addHandler( h, ResizeEvent.getType() );
}

I've also tried explicitly calling onResize() in the view's onResize()
like this, but it doesn't call the SplitLayoutPanel's on onResize().

public void onResize()
{
Widget child = getWidget();
if( child instanceof RequiresResize )
((RequiresResize)child).onResize();
}

Any ideas what I'm doing wrong?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment