Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7011705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:09:40+00:00 2026-05-27T22:09:40+00:00

I am stuck in getting an absolute position of DialogBox . I know it

  • 0

I am stuck in getting an absolute position of DialogBox. I know it is the common problem (and strange workaround) for PopupPanel (which is parent to DialogBox) to set it, but what if I want to get it, what is the exact moment when the box attached to DOM? Neither overriding show nor onAttach nor show does not help:

class MyDialog extends DialogBox {

    public MyDialog(. . .) {
        ComplexPanel vert = new VerticalPanel();
        vert.add("Test");
        vert.add(new Button("Close", new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                MyDialog.this.hide();
            }
        }));
        setWidget(vert);

        this.addAttachHandler(new AttachEvent.Handler() {

            @Override
            public void onAttachOrDetach(AttachEvent event) {
                if (event.isAttached()) Log.debug("attach:"+MyDialog.this.getAbsoluteLeft() +";"+
                                                            MyDialog.this.getAbsoluteTop());
            }
        });
    }

    @Override
    protected void onLoad() {
        super.onLoad();
        Log.debug("load:"+this.getAbsoluteLeft() +";"+this.getAbsoluteTop());
    }

    @Override
    public void show() {
        super.show();
        Log.debug("show:"+this.getAbsoluteLeft() +";"+this.getAbsoluteTop());
    }

}

So when I call new MyDialog().show();, all this lines do log 0;0, however dialog is positioned in center of a page. But what I want is the sum of the chain of offsetParent positions. (And they are 0 in these moments even in JavaScript, if use JSNI to check this)

Again, setPopupPositionAndShow allows to set position but not get it 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:09:40+00:00Added an answer on May 27, 2026 at 10:09 pm

    Finally, I’ve got this to work:

    @Override
    public void setPopupPosition(int left, int top) {
        super.setPopupPosition(left, top);
        if (this.isAttached()) Log.debug("setPos:"+this.getAbsoluteLeft() +";"+this.getAbsoluteTop());
    }
    

    It gets the proper position and I hope it is the right way to do it and setPopupPosition is called every time. You will even call it manually when using setPopupPositionAndShow.

    I think it will be wise to let this question stay at SO “for future generations”.


    Upd. If you plan to call center(...) or some similar method of your dialog, be aware that setPopupPosition will be called twice or more times (may be first time with 0, 0), even if you’ll check if it isAttached(). Add some additional check to ensure that positions are correct in current call.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting stuck on this problem. It seems simple but for some reason
I feel like I'm asking a lot of questions, but I keep getting stuck.
This is probably easy but I am getting stuck: when I build a solution
I'm trying to create a custom search but getting stuck. What I want is
I am getting stuck on heapSort. I have some code but I think its
I'm trying to get an installation of webOrb 3.6.0.3 working, but am stuck getting
This should be a fairly straight forward python question, but I'm getting stuck getting
I am getting stuck in a page,where I'm using selectbox & checkbox,and they will
I'm stuck in getting the product url in a product collection. I have this
I am new to rails and getting stuck a lot trying to develop my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.