Wednesday, March 2, 2011

Custom Components & Widget.getOffsetWidth

Hi,
I am building a custom GWT 2.1 toolbar widget that allows the insertion of spacers. The width of these spacers is adjusted so that components are always distributed evenly across the width of the toolbar (e.g. button - spacer -button - spacer -button creates a toolbar with one button left-, center- and right-aligned).
The basic calculuation is:
size of toolbar = size of all components + size of spacers
In Safari this calculation does not work precisely, if I get the size of components using .getOffsetWidth(), the last component is always wrapped into the next line. I tested my calculations with the Safari Inspector and all values seem to be correct. So a parent div tag with a width of w cannot hold sub-tags whose widths add up to exactly w or even w-2. Any clue what this might be caused by?
Furthermore I am struggling with GWT "hooks". After adding all components to the toolbar I need to initially scale the spacers. For this I need the values of getOffsetWidth() to be correct. I tried performing this calculation in onAttach and onLoad, but the width of the parent component (FlowPanel) is not yet set. Is there another method that is called the initialization of a component after the component has been inserted into the DOM?

Thanks for your help
Jerome

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate