Photoshop ScriptUI:显示一个对话框窗口,将其关闭,再次显示将显示一个空的完整尺寸窗口 [英] Photoshop ScriptUI: Show a dialog window, close it, show it again gives an empty full size window

查看:259
本文介绍了Photoshop ScriptUI:显示一个对话框窗口,将其关闭,再次显示将显示一个空的完整尺寸窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在用JavaScript编写的Photoshop CC 2015(Windows 10)脚本中,我正在循环处理活动文档的所有层,并希望在每个步骤中显示一个设置对话框.

In my script for Photoshop CC 2015 (Windows 10), written in JavaScript, I am processing all layers of the active document in a loop and want to show a setup dialog in each step.

为简化起见,请使用以下工作示例.窗口是在循环外部定义的,在这里剥离的其他步骤中,循环中的每个步骤都会显示一次该窗口:

For simplification, take the following working example. The window is defined outside the loop, and among other steps which are stripped here, the window is shown once every step in the loop:

#target photoshop

var w = new Window('dialog', 'Title');
var b = w.add('button', undefined, 'OK');

for (var i = 0; i < 3; i++) {
    // other code
    w.show();
    // other code
}

执行它时,将按预期显示一个小的对话框窗口,其中只有一个确定"按钮.您可以使用确定"按钮将其关闭. 但是每个连续的w.show()都会产生一个空白窗口,几乎占据了整个屏幕,没有任何控件.只能使用ESC键将其关闭.

When you execute it, a small dialog window with just one "OK" button appears, as expected. You can close it using the "OK" button. But every consecutive w.show() produces a blank window that almost fills the entire screen, with no controls whatsoever. It can only be closed using the ESC key.

我尝试覆盖b.onClick事件并手动调用close(),但这并没有任何改变.

I tried overriding the b.onClick event and manually call close(), but that did not change anything.

在检查w变量时,很明显bounds分别为locationsize有所更改.我尝试将这些值重置为以前的状态,并恢复了窗口大小.但是,该按钮仍然不可见.

Upon inspection of the w variable, it is obvious that the bounds, respectively location and size somehow got changed. I tried resetting these values to their previous state, and the window size is restored. However, the button is still not visible.

我错过了什么吗?如何使对话框窗口多次正确显示?

Am I missing something? How can I get the dialog window to show up correctly more than once?

推荐答案

尝试使用此代码,它对我来说适用于Photoshop CC + OSX.

try this code, it works for me with Photoshop CC + OSX.

w.close()销毁对话框窗口,因此您应该重新创建.

w.close() destroy dialog window, so you should create again.

按下一个名为确定"的按钮,按下返回键与w.close()相同.

press a button named 'ok', press return key are same as w.close().

#target 'photoshop'

for (var i = 0; i < 3; i++) {
  var w = W();
  $.writeln(w.show());
}

function W () {
  var w = new Window('dialog', 'Title');
  var b = w.add('button', undefined, 'OK', {name:'ok'});
  return w
}

这篇关于Photoshop ScriptUI:显示一个对话框窗口,将其关闭,再次显示将显示一个空的完整尺寸窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆