Skip navigation
Currently Being Moderated

Getting Absolute Position of a Floating/Dockable Palette

Nov 2, 2011 2:50 PM

Tags: #dockable_panel #floating_panel

Hi,

 

Is it possible in AE scripting/ScriptUI to get the absolute window position of a floating dockable palette, or one of its child elements?

 

I'm trying to open a new dialog directly underneath a button when it is clicked, so I need screen coordinates of either the button itself or the palette (from which I can then calculate the relative position).

 

Obviously if I report the bounds or location of a button it returns it to me relative to its container. If I attempt to access frameBounds on the palette I get an "undefined" error, whereas the bounds of the palette always have 0,0 coordinates for the top-left.

 

If neither is possible, can you get the mouse pointer coordinates instead?

 

Many thanks,

 

Christian

 
Replies
  • Currently Being Moderated
    Nov 2, 2011 3:11 PM   in reply to Christian Lett

    This gives me the upper left corner of my floating dialog:

     

    alert(uiPal.frameBounds.left + ", " + uiPal.frameBounds.top);

     

    Dan

     
    |
    Mark as:
  • Currently Being Moderated
    May 29, 2012 12:00 PM   in reply to Christian Lett

    Not sure but 2 things to throw into the mix....

     

    Accessing something relatively...   thisButton.parent.parent.parent.bounds

     

    Also in the object model I noticed there is

    Button.bounds as well as Button.windowBounds

     

    might be of some help.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 3:35 PM   in reply to Christian Lett

    Using $.screens will give you the monitor screen size and maybe help in pin pointing your window location.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2012 4:56 AM   in reply to David Torno

    Actually I'm trying to work this out at the moment, trying to find the position of a docked panel.

    //=======================================================

    var w = Window.find("","TheWindowName");

    alert(w.frameBounds.left + ", " + w.frameBounds.top);

    //=======================================================

    I think it's excluded from the Script UI (window, palette, dialog).  Alternatively the Scripting guide(UI) says you can put in a

    resourceName which I presume is a variable?

    Any pointers appreciated...?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2012 8:28 AM   in reply to Alan_AEDScripts

    So here I am using a global to reference a docked panel...

    //=======================================================

    var pnl = (thisObj instanceof Panel) ? thisObj : new Window("palette", "", [200, 200, 1265,242]);

    gReference = pnl;

     

    //So from another script...

    //instead of :

    var w = Window.find("","TheWindowName");

     

    //using this

    var w = Window.find(gReference);

    alert(gReference.windowBounds); // incorrect because it's a panel not a window.

    alert(gReference.location); // [0,0] relative.


    //finds the docked panel... all good but the frameBounds/windowBounds property doesn't exist for "Panel".

    //so I can't find the screen position of an element only it's relative position in the panel.

    //dead end?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 28, 2012 2:54 PM   in reply to Alan_AEDScripts

    Just found out that it's possible to retrieve the cursor's absolute location using an eventlistener. From the ScriptUI for Dummies guide by Peter Kahrel:

    var w = new Window ("dialog");

    var b = w.add ("button", undefined, "Qwerty");

    b.addEventListener ("click", function (k) {whatsup (k)});

    function whatsup (p)

    {

    if (p.button == 2) {$.writeln ("Right-button clicked.")}

    if (p.altKey) {$.writeln ("Alt key pressed.")}

    $.writeln ("X: " + p.clientX);

    $.writeln ("Y: " + p.clientY);

    }

    w.show ();

    But this still gives a relative value. The CS6 Tools Guide (p.153) says you can also use screenX and screenY. So slightly modified:

    var w = new Window ("dialog");

    var b = w.add ("button", undefined, "Qwerty");

    w.addEventListener ("click", function (k) {whatsup (k)});

    function whatsup (p)

    {

    $.writeln ("X: " + p.screenX);

    $.writeln ("Y: " + p.screenY);

    w.close();

    }

    w.show ();

    This returns the absolute location when the button is clicked. Which in turn, you can pass to the bounds of the new window.

     

    Alternatively you might be able to show() a group or UI element when the button is clicked.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points