Wednesday, March 2, 2011

Re: Custom Components & Widget.getOffsetWidth

There is only onLoad I think. getOffsetWidth can only give you the correct value if the element is already rendered by the browser, otherwise its zero. Its also zero if the element is attached to the DOM but display:none (or maybe display:hidden) is set on some parent element as the browser won't render it. Maybe a deferred command could help you (see Scheduler.get().scheduleXXXX() )

But wouldn't it be easier to define three areas in you toolbar, one for each position: left, center, right and then put toolbar buttons in these areas? At least thats what I do. These areas can be positioned with css (the center area may be tricky but the left and right area are just divs with float:left, float:right).

In your custom toolbar composite you could add methods like

@UiChild
public void addLeft(Widget w) { //add w to left aligned area }

@UiChild
public void addRight(Widget w) { //add w to right aligned area }

With these methods you can use the toolbar in UiBinder like

<custom:ToolBar>
  <custom:left>
     //your left aligned toolbar buttons
  </custom:left>
  <custom:right>
     //your right aligned toolbar buttons
  </custom:right>
</custom:ToolBar>

That way you do not have to calculate anything and css will do the work for you.

--
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