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

Solve the misalignment problem of "zoom" windows

New Here ,
Feb 26, 2024 Feb 26, 2024

Copy link to clipboard

Copied

In the process of using ScriptPanel_2, there is a problem that has troubled me for a long time. That is, every time the window is zoomed in or out, the new window will be misaligned, And absolutely the purpose of the designer must be made it zoom in the original position.
An observed phenomenon is that the magnitude of the misalignment is proportional to the distance between the window and the upper left corner of the screen. When I place the window closer to the upper left corner of the screen, the misalignment becomes smaller. The closer the window is to the lower right corner of the screen, the misaligned window will even fly out of the screen and cannot be found.

7878787.jpg

This problem made me so confused. After a long period of exploration, I finally found out that it was related to the screen settings of my Windows 10. In this picture you can see the setting:150%, When a jsx script create a new window, the location and the size of it will enlarge 150%. But I can't restore it to 100%, otherwise the desktop icons and software interface will be too small to see clearly.

微信截图_20240226173127.jpg

Although the reason was found, the solution was also very tortuous. Anyway, it has solved. The point is using the "onShow() callback" method.
Here is sample code:

#target illustrator
#targetengine main
//creat big window----------------------------------------------------------------
var paletteWindow = new Window('palette', 'My Panel', undefined, {borderless: false}); 
paletteWindow.onShow = function() {
  paletteWindow.location = tinyWindow.location;
};
var eObj = paletteWindow.add("edittext",[10,10,200,32],"-");
paletteWindow.onMove = function() {
  eObj.text = "location:"+paletteWindow.location;
}; // Detect Synclocation,You can replace it with other components
var btn_min = paletteWindow.add('button', undefined, 'Minimize');
paletteWindow.show()
//creat small window--------------------------------------------------------------
var tinyWindow = new Window('palette', 'MiniPanel', undefined, { borderless: false, closeButton: false }); tinyWindow.margins = [0,0,0,0];
tinyWindow.onShow = function() {
  tinyWindow.location = paletteWindow.location;
};
btn = tinyWindow.add("button", [-30,-30,120,120], "max");
btn.size = [90, 80];
//Reduce big window-----------------------------------------------------------
btn_min.onClick = function(){
  tinyWindow.show();
  paletteWindow.close();
};
//Enlarge small window---------------------------------------------------------
btn.onClick = function(){
  paletteWindow.show();
  tinyWindow.close();
};

 

TOPICS
Scripting

Views

49

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
no replies

Have something to add?

Join the conversation
Adobe