Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to align window element in center top of the window?

    Hi,

    As autoCenter property displays the window in center of the page, I want to show the window horizontally center and vertically top in the page.

    Please help. I tried few things and it's not working out for me.

    Thanks.

    #2
    Hi isomorphic guys,

    I also need answer to this question. Please provide it ASAP, thx.
    My particular problem: how to place the window at the right bottom corner of the browser.

    Cheers,
    Alexey
    Last edited by alexey.wiesner; 14 Jun 2011, 07:25.

    Comment


      #3
      have you tried using moveTo?

      Comment


        #4
        and how can moveTo help to solve this problem of alignment?
        My problem: how to place the window at the right bottom corner of the browser.

        Comment


          #5
          The core GWT Window API can give you screen dimensions and getVisibleHeight()/Width() gives you the SmartGWT Window widget's dimensions, then it's just moveTo() the difference.

          Comment


            #6
            I write my window as component. And it should be able to place itself to the right bottom corner of the screen, so how can this component retrieve the screen dimensions in order to use moveTo?

            Comment


              #7
              Something like this will do it:

              Code:
              function placeCanvas (canvas, vAlign, hAlign) {
                  // default top/left
                  var top = 0, left = 0;
              
                  // shift the top
                  if (vAlign == "bottom") top = Page.getHeight() - canvas.getVisibleHeight();
                  else if (vAlign == "center") top = (Page.getHeight() - canvas.getVisibleHeight()) / 2;
              
                  // shift the left
                  if (hAlign == "right") left = Page.getWidth() - canvas.getVisibleWidth();
                  if (hAlign == "center") left = (Page.getWidth() - canvas.getVisibleWidth()) / 2;
              
                  // move the canvas
                  canvas.moveTo(left, top);
              }

              Comment


                #8
                Thanks a lot for rapid and exact answer! The code helped me well!

                Comment


                  #9
                  Would be nice if you could include this as general feature, since this might be interesting for other users.

                  Comment


                    #10
                    If you put your widgets inside some other canvas that fills the page, like a layout, you can use the built-in snapTo feature (see the docs)

                    Comment

                    Working...
                    X