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

window.frameLocation getting UI-scaled! [scripting]

Community Beginner ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

In ID v17.3 I have a dialog that I need to close, then re-open exactly at the same spot after doing some work on the Document, i.e.

var oldDlg = new MyDialog();
oldDlg.show();
var oldLocation = oldDlg.win.frameLocation; //e.g. [100, 100];
// ... do some stuff to the Document ...
var newDlg = new MyDialog();
newDlg.win.frameLocation = oldLocation; //tried doing this from onShow, but no difference
newDlg.show(); //doesn't show at the same place, shows up at 2x old coordinates
var newLocation = newDlg.win.frameLocation; //this is now e.g. [200, 200]!!!

In other words, the frameLocation that's reported after the show() is MULTIPLIED by the current internal UI scaling factor, 2x in this case. Sure enough, the multiplication factor changes depending on the UI Scaling preference, so UI Scaling has to be in effect. Yet, show() of the new dialog needs frameLocation in UN-multiplied units!

This smells like a bug. I can work around it by pre-adjusting oldLocation by multiplying by (oldDlg.win.preferredSize[0] / oldDlg.win.size[0]), but what if Adobe come back and fix this someday and break my script in the process? (BTW Adobe, the discrepancy of preferredSize vs size is also nonsensical.)

So, is this a feature or a bug? If so, in which versions?

Does anybody have a safer idea for a workaround?

Thanks!

TOPICS
Bug , Scripting

Views

245

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 17, 2022 Aug 17, 2022

Hi @chartbot 

 

This is a CC bug:

https://www.indiscripts.com/post/2021/03/scriptui-vs-ui-scaling

 

In short, the Window metrics (location, size, etc) are set in SUI coordinates but they return screen coordinates:

 

Best,

Marc

Votes

Translate

Translate
Guide ,
Aug 17, 2022 Aug 17, 2022

Copy link to clipboard

Copied

Hi @chartbot 

 

This is a CC bug:

https://www.indiscripts.com/post/2021/03/scriptui-vs-ui-scaling

 

In short, the Window metrics (location, size, etc) are set in SUI coordinates but they return screen coordinates:

 

Best,

Marc

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 19, 2022 Aug 19, 2022

Copy link to clipboard

Copied

Thanks so much for that, Marc!

From your post I see we're both doing the same ugly workaround of scaling the location by the ratio of expected vs. SUI-reported size. This leaves me concerned that Adobe will fix the location-scaling problem in some future version of ID, effectively turning the workaround into a bug in my code!

You're much more plugged-in with Adobe than I am, and you're doing it; should I understand that you have reason to believe that Adobe will leave this "feature" as-is, or are you just planning to add version-dependent code if & when they change it?

Thanks again!

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 21, 2022 Aug 21, 2022

Copy link to clipboard

Copied

LATEST

Hi @chartbot 

 

quote

(…) This leaves me concerned that Adobe will fix the location-scaling problem in some future version of ID, effectively turning the workaround into a bug in my code! (…)

 

  • If you compute ScriptUI.SCALING as shown at the end of my paper and use those multipliers wherever needed, this shouldn't lead to introduce a bug in the event Adobe would fix the problem in a future version of ScriptUI, because the factors would then become [1, 1] along each axis, making them transparent.
  • Most of us here are fairly certain that ScriptUI will never be cleaned up by Adobe. None of the critical bugs reported since CC appeared have gotten a serious fix. Today the spotlight is on UXP…

 

Best,

Marc

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