How to position the GWT dialog to the bottom right corner of the browser relatively to the Size of the Browser?

415 views
Skip to first unread message

Tom

unread,
Oct 4, 2013, 10:44:14 AM10/4/13
to google-we...@googlegroups.com
I want to position the GWT dialog to the bottom right corner of the browser. There is a fixed footer in my website (height=50px) & I want dialog to be shown as in the following pic.


Look at this code:

    int browserHeight=Window.getClientHeight();
    int browserWidth=Window.getClientWidth();
    dialog.setPopupPosition(browserWidth-dialog.getElement().getClientWidth(), browserHeight-dialog.getElement().getClientHeight());
    dialog.show();


The above code will make the position starts from the very last pixel of the browser (ie bottom=0 & right=0), which is not what i expect. Also, I don't like to use css cos browser incompatible problem.

The 2nd requirement is that, I want the dialogbox to stay in the desired position no matter how users re-size the window browser to smaller or bigger. It means when browser got shrinked or expanded, the dialogbox will still be located near at the bottom right corner of the browser & lie on top of the footer.

so, How to position (via coding) the GWT dialog to the bottom right corner of the browser relatively to the Size of the Browser?

Tom

unread,
Oct 4, 2013, 12:24:21 PM10/4/13
to google-we...@googlegroups.com
it will be simple if we know the exact width & height of dialogbox. we also need to to know the parentPanel / parentLayoutPanel of dialogbox

This code will work but it is not the optimum code

dialogBox.setWidth("300px");
dialogBox.setHeight("300px");
dialogBox.setPopupPosition(parentLayoutPanel.getOffsetWidth()-300,parentLayoutPanel.getOffsetHeight()-300-50);

but how to know the width + height of dialogbox dynamically?

Jens

unread,
Oct 4, 2013, 12:39:25 PM10/4/13
to google-we...@googlegroups.com
Use Dialog.setPopupPositionAndShow(PositionCallback) to get the correct width/height values of your dialog box.

-- J.

Tom

unread,
Oct 4, 2013, 12:49:30 PM10/4/13
to google-we...@googlegroups.com
Fantastic Jen, thax u very much

this work
fialogBox.setPopupPositionAndShow(new PositionCallback(){

@Override
public void setPosition(int offsetWidth, int offsetHeight) {
// TODO Auto-generated method stub
dialogBox.setPopupPosition(parentDockLayoutPanel().getOffsetWidth()-         dialogBox.getOffsetWidth(), 
parentDockLayoutPanel().getOffsetHeight() - dialogBox.getOffsetHeight()-50);
}
   
});
Reply all
Reply to author
Forward
0 new messages