0

我有以下脚本:

picked = myItems (['item 1', 'item 2', 'item 3', 'item 4', 'new item 1', 'new item 2']); 


function myItems (templates) {
var w = new Window ('dialog {text: "Item List", alignChildren: "fill"}');

 var entry = w.add ('edittext {active: true}')
  entry.graphics.font= ScriptUI.newFont ("Arial", "Bold", 12);
 var list = w.add ('listbox', [0, 0, 200, 100], templates);
 list.selection = 0;

list.graphics.font= ScriptUI.newFont ("Arial", "Italic", 14);

entry.onChanging = function ()
{
var temp = entry.text,
 tempArray = [];
for (var i = 0; i < templates.length; i++)

 if (templates[i].toLowerCase().indexOf (temp) == 0)
tempArray.push (templates[i]);

else if (templates[i].toUpperCase().indexOf (temp) == 0)
tempArray.push (templates[i]);

if (tempArray.length > 0)
 {
 tempList = w.add ("listbox", list.bounds, tempArray, {scrolling: true});

 tempList.graphics.font= ScriptUI.newFont ("Times New Roman", "Regular", 14);
 w.remove(list);
 list = tempList;
 list.selection = 0;
 list.onDoubleClick=function(){

if (list.selected){
     var buttonname = list.selection.text
     var templatefile = new File (searchpath + "/" + buttonname + '.psd');
               mainfunction (templatefile)
}
w.close();
}
 }
} 

ListItem.add

 var B = w.add ('button', undefined, 'Ok', {name: 'ok'}) 


list.onDoubleClick=function(){

if (list.selected){
     var buttonname = list.selection.text
     var templatefile = new File (searchpath + "/" + buttonname + '.psd');
               mainfunction (templatefile)
}

w.close();
}

 if (w.show () != 2){
     var buttonname = list.selection.text
     var templatefile = new File (searchpath + "/" + buttonname + '.psd');
               mainfunction (templatefile)

 }
w.close();
}

在 ExtendScript 上,这会创建一个带有以下列表的搜索框。使用 Tab 键可以在搜索框和列表之间切换。我还希望能够使用箭头键在搜索框和列表之间切换。任何人都可以建议这是否可能?

我在 jQuery 上看到了一些结果,但遗憾的是 ExtendScript 不支持 jQuery,但它确实支持 ScriptUI。

非常感谢,

编辑

我发现这是一个解决方案:

    w.addEventListener ("keydown", function (kd) {pressed (kd)});
function pressed (k)
{
if (k.keyIdentifier === "Down" && entry.active = true)
    list.active = true;
    else if (k.keyIdentifier === "Up" && list.active = true)
    entry.active = true ;
    else 
list.scrolling = true;
}

但是,它不适用于 Photoshop CC 2014。有谁知道我可以进行哪些更改以实现向后兼容性?

4

0 回答 0