自从我对ExtendScript / ScriptUI遇到问题已经有一段时间了,这使我感到困惑不已,以至于不得不不得不向这里的专家求助。我想这意味着我正在学习! :〜)以下是我试图开始工作的代码片段。从理论上讲,它应该允许打开1个,2个或3个调色板窗口(取决于数组true中有多少pSpecial个语句),然后等待用户在每个窗口中选择一些项并单击按钮在第四个调色板中。对于这个问题的复杂性,我预先表示歉意。我对所有这些都还比较陌生,因此代码可能很难遵循,但可能可以归结为只打开一个或两个简单的调色板。var aFoils = ["Choose one…", "-", "Shiny Gold", "Matte Gold", "Shiny Silver", "Matte Silver", "Copper", "Green", "Dark Purple", "Blue", "Teal", "Red", "Burgundy"];var swatchObjects = ["123u", "871c", "Black"];var pSpecial = [false, true, false];// The xDelta variable specifies how far to move the palettes away from each other.// xMove will be the X LOCATION for the new window.var xDelta = 300;var xMove;var hsChecks = [], hsDropdowns = [], dbRadios = [], ebRadios = [];var hotstampColors = [];var debossColor, embossColor;// If one of the specials is checked (hotstamp/deboss/emboss), then let's handle it.// Define the Hotstamp window.var hotstampWin = new Window("palette"); hotstampWin.onShow = function () { hotstampWin.location.x = xMove; } hotstampWin.add("statictext", undefined, "Please select Hotstamping foils:"); var hsGroups = hotstampWin.add("group"); var hsCheckGrp = hsGroups.add("group"); hsCheckGrp.orientation = "column"; hsCheckGrp.alignChildren = "left"; var hsDDGrp = hsGroups.add("group"); hsDDGrp.orientation = "column"; hsDDGrp.alignChildren = "left"; for (var h = 0; h < swatchObjects.length; h++) { hsChecks.push(hsCheckGrp.add("checkbox", undefined, swatchObjects[h])); hsDropdowns.push(hsDDGrp.add("dropdownlist", undefined, aFoils)); }// Define the Deboss window.var debossWin = new Window("palette"); debossWin.onShow = function () { debossWin.location.x = xMove; } debossWin.add("statictext", undefined, "Please check which color is Debossed:"); var dbGroup = debossWin.add("panel"); for (var d = 0; d < swatchObjects.length; d++) { dbRadios.push(dbGroup.add("radiobutton", undefined, swatchObjects[d])); }// Define the Emboss window.var embossWin = new Window("palette"); embossWin.onShow = function () { embossWin.location.x = xMove; } embossWin.add("statictext", undefined, "Please check which color is Embossed:"); var ebGroup = embossWin.add("panel"); for (var e = 0; e < swatchObjects.length; e++) { ebRadios.push(ebGroup.add("radiobutton", undefined, swatchObjects[e])); }// Define the window with the "Continue" button.var continueWin = new Window("palette"/*, undefined, undefined, {borderless: true}*/); continueWin.onShow = function () { continueWin.location.y = ($.screens[0].bottom / 2) - (continueWin.size[1] / 2) + 75 + (25 * swatchObjects.length); } var bContinue = continueWin.add("button", undefined, "Continue", {name: "ok"}); bContinue.onClick = function () { if (dbRadios.length > 0) {debossColor = selected_rbutton(dbGroup);} if (ebRadios.length > 0) {embossColor = selected_rbutton(ebGroup);} if (hsChecks.length > 0) { for (var j = 0; j < hsChecks.length; j++) { if (hsChecks[j].value) { hotstampColors.push([swatchObjects[j], hsDropdowns[j].selection.text]); } } } aSpecial[0].close(); this.parent.close(); }function selected_rbutton (rbuttons){ for (var i = 0; i < rbuttons.children.length; i++) { if (rbuttons.children[i].value == true) {return rbuttons.children[i].text;} }}var aSpecial = new Array;if (pSpecial[0]) {aSpecial.push(hotstampWin);}if (pSpecial[1]) {aSpecial.push(debossWin);}if (pSpecial[2]) {aSpecial.push(embossWin);}switch (aSpecial.length){ case 1: aSpecial[0].show(); xMove = ($.screens[0].right / 2) - (aSpecial[0].size[0] / 2); aSpecial[0].show(); if (continueWin.show() == 1) { aSpecial[0].close(); continueWin.close(); } else { exit(); } break; case 2: aSpecial[0].show(); xMove = ($.screens[0].right / 2) - (aSpecial[0].size[0] / 2) - xDelta; aSpecial[0].show(); aSpecial[1].show(); xMove = ($.screens[0].right / 2) - (aSpecial[1].size[0] / 2) + xDelta; aSpecial[1].show(); if (continueWin.show() == 1) { aSpecial[0].close(); aSpecial[1].close(); continueWin.close(); } else { exit(); } break; case 3: aSpecial[0].show(); xMove = ($.screens[0].right / 2) - (aSpecial[0].size[0] / 2) - (xDelta * 1.5); aSpecial[0].show(); aSpecial[1].show(); xMove = ($.screens[0].right / 2) - (aSpecial[1].size[0] / 2); aSpecial[1].show(); aSpecial[2].show(); xMove = ($.screens[0].right / 2) - (aSpecial[2].size[0] / 2) + (xDelta * 1.5); aSpecial[2].show(); if (continueWin.show() == 1) { aSpecial[0].close(); aSpecial[1].close(); aSpecial[2].close(); continueWin.close(); } else { exit(); } break; default: break;}我在这段代码中遇到的问题是,在运行时,调色板会打开,然后立即关闭。用户互动是没有机会的。他们为什么关闭?另外,我尝试将一个或多个窗口更改为Continue类型,但随后该窗口将接管,并且直到该窗口被关闭后,用户才能与其他任何窗口交互。我也乐于接受其他想法,例如将所有内容组合到一个对话框窗口中,但是我希望它根据该dialog数组中有多少个true动态调整大小。 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 如果您从ESTK运行它,它将起作用。至少在我的IDCC中。但是要使其从ID脚本面板运行,您必须添加:#targetengine'foo';在脚本的开头。 (或任何其他targetengine)请注意,在关闭InDesign之前,#targetengine 'foo'中的所有全局变量都将存在。因此,您应该将脚本包装成一个函数。我也建议使用return代替exit() (adsbygoogle = window.adsbygoogle || []).push({});
10-08 16:47