First of all, Thank You Adam. This is one of those things that I spent like 4 hours on and finally just asked about.
I put my absolute positioning code inside a DefferedCommand. Have not seen it fail yet. So thank you, it seems to work. Still, I do wonder. What is the deterministically appropriate way to deal with this? For all I know the DefferedCommand may be the appropriate way to deal with this, as it may truly guarantee that code is not run till after all other events are run. Assuming that "repositioning stuff as things are added to the DOM" is just another event, then as long as DefferedCommand always guarantees that it will add to the end, then it is probably correct. However, is there some more direct way to do this. Like, could I wrap a widget in something (or override some handler) such that I can guarantee execution of code only after the widget has been fully positioned and their currently exist not other DOM modifying events in the queue? Also, in closing, is there more information somewhere on exactly how widgets are added, positioned, and rendered. I would also be interested in any callbacks (or equivalent) that I can override at any point in said process. Thanks all. On May 1, 11:14 pm, Adam T <adam.t...@gmail.com> wrote: > sometimes it's worth wrapping any repositioning up in a > DeferredCommand to give the browser a chance, i.e. take you code that > does something like this: > > int x = X.getAbsoluteTop; > int h = X.getOffsetHeight(); > W.setWidgetPostition(x,y); > W.setWidth(h/2+"px"); > > and make it > > DeferredCommand.addCommand(new Command(){ > public void execute(){ > int x = X.getAbsoluteTop; > int h = X.getOffsetHeight(); > W.setWidgetPostition(x,y); > W.setWidth(h/2+"px"); > } > > }); > > now the positioning code will execute a little later giving the > browser chance to have redrawn everything and you should get more > consistent answers. > > //Adam > > On 2 Maj, 01:12, Stephen Cagle <same...@gmail.com> wrote: > > > I have a Composite widget within which I have overridden the onResize > > () method. Some of the element widgets of this widget position > > themselves relative to other widgets. That is to say, I sometimes > > position widget X using .getAbsoluteTop() and .getOffsetHeight(). > > Unfortunately, sometimes .getAbsoluteTop sometimes returns a pretty > > random value. I think this is because I am re-populating/creating a > > lot of the widgets upon resize. So maybe I am getting the size of the > > widget "as it is being built". What should I do to deal with this. I > > need to position things absolutely relative to other widgets, but > > within the onResize() method, I am getting (occasionally) odd results? > > --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---