• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Opening window on mouse.

Community Beginner ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Hello!

I am attempting to write a script that opens a dialog window. How would I be able to have the window open at the current mouse position?

TOPICS
Actions and scripting

Views

365

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Aug 18, 2022 Aug 18, 2022

 

var cursor = (getXY());
var w = new Window("dialog", 'Test');
w.preferredSize = [200, 200];
w.location = [cursor[0], cursor[1]]
w.show();

function getXY() {
    var w = new Window("dialog {alignChildren: ['fill','fill'], margins: 0, opacity : 0.01}"),
        g = w.add("button"),
        X, Y;
    w.preferredSize = [$.screens[0].right, $.screens[0].bottom]
    g.addEventListener('mouseover', handler)
    function handler(evt) { w.close(); X = evt.screenX, Y = evt.screenY }
    w.show();
    r
...

Votes

Translate

Translate
Adobe
Guide ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

 

var cursor = (getXY());
var w = new Window("dialog", 'Test');
w.preferredSize = [200, 200];
w.location = [cursor[0], cursor[1]]
w.show();

function getXY() {
    var w = new Window("dialog {alignChildren: ['fill','fill'], margins: 0, opacity : 0.01}"),
        g = w.add("button"),
        X, Y;
    w.preferredSize = [$.screens[0].right, $.screens[0].bottom]
    g.addEventListener('mouseover', handler)
    function handler(evt) { w.close(); X = evt.screenX, Y = evt.screenY }
    w.show();
    return [X, Y]
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Thank you! If I understand correctly, this is a function that creates a fullscreen button with a mouseover event listener that closes and returns the X Y values?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Yes that's right.

Unfortunately, ScritpUI does not allow us to get the mouse coordinates directly, so we have to resort to such tricks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

Makes sense. I added

w.opacity = 0;

to the function to make it a little less jarring as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 18, 2022 Aug 18, 2022

Copy link to clipboard

Copied

LATEST

It's strange that this works.

For me, when w.opacity = 0, the eventListener stops firing (that is, the window elements do not catch the event). That is, i need to set any value of transparency, except zero.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines