problem with getting height of widget

27 views
Skip to first unread message

Thomas Lefort

unread,
Dec 9, 2011, 3:02:42 PM12/9/11
to google-we...@googlegroups.com
I have been stuck with this problem for too long and I just can't find a solution.

The problem is I want to render a popup which has a non fixed size and place it half way next to a widget. For this I need to get the panel height, with getOffsetHeight, once it is rendered. I do this after calling the show method. However the problem is that the getOffsetHeight returns 0 the first time the popup is created and therefore the popup is not positioned where I want it to be.

I reuse it later on, after hidding it and then the height is returned correctly. The problem is really with the first time it is shown. I tried shoing it and hiding it immediately and the showing it again, but it still didn't solved the problem, which is pretty strange to me.

Anyway if anyone has a way of solving this issue, please let me know!

Thanks,

Thomas

Jens

unread,
Dec 9, 2011, 3:19:25 PM12/9/11
to google-we...@googlegroups.com
You can use 

popupPanel.setPopupPositionAndShow(new PositionCallback() {

  public void setPosition(int offsetWidth, int offsetHeight) {
     //do your calculations. Offset sizes shouldn't be 0 here
  }
 
});

-- J.

Thomas Lefort

unread,
Dec 10, 2011, 4:14:28 PM12/10/11
to Google Web Toolkit
Thanks! Just tried, sounded like a great idea, but it doesn't work
unfortunately. It's really as if the widgets I add inside the panel
are rendered/added after. Really strange...

Alfredo Quiroga-Villamil

unread,
Dec 10, 2011, 6:38:55 PM12/10/11
to google-we...@googlegroups.com
Try the following:

                 Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                    

                    @Override

                    public void execute() {

                        // Try to get the size here ...

                    }

                });


Regards,

Alfredo


--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton


Jens

unread,
Dec 11, 2011, 8:19:50 AM12/11/11
to google-we...@googlegroups.com
Hm ok, then you have to use a deferred command as Alfredo already mentioned. The command will be executed after all of your code has been executed and the browser had time to render things. This should definitely work.

-- J.

jhulford

unread,
Dec 11, 2011, 9:57:21 AM12/11/11
to Google Web Toolkit
Are you using any DeferredCommands that would result in your widget's
content not being able to be determined when it's outer container is
actually added to the DOM? It really sounds like your widget
initially doesn't have any real content at the point when show() is
being called and is actually being built out in a callback running off
the event queue.

Thomas Lefort

unread,
Dec 12, 2011, 3:50:32 AM12/12/11
to Google Web Toolkit
Hi Thanks for all the tips. The deferred didn't work, it sort of
hangs. I ended up showing/hiding the popups at start up, and that
seems to be enough.
Reply all
Reply to author
Forward
0 new messages