0

I have the below script:

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();
}

On ExtendScript this creates a search box with a list below. Using the tab key you can switch between the search box and the list. I want to be able to also use the arrow keys to switch between the search box and the list. Can anyone advise if this is possible?

I have seen some results on jQuery, but sadly ExtendScript does not support jQuery, however it does support ScriptUI.

Many Thanks,

EDIT

I found this to be a resolution:

    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;
}

However, it does not work with Photoshop CC 2014. Does anyone know what I may be able to change to allow backwards compatibility?

RobC
  • 22,977
  • 20
  • 73
  • 80
Dantr1c
  • 1
  • 1
  • Take a look into Peter Kahrels ScriptUI Guide http://www.kahrel.plus.com/indesign/scriptui.html There is a section about Listening to the keyboard and eventListener – fabianmoronzirfas Apr 13 '17 at 16:56
  • Thank you, I have that guide downloaded as a resource. It has helped me create the dialog box and listbox, it is transitionally the keyboard functions to act like the tab key that I am struggling with. – Dantr1c Apr 13 '17 at 19:37

0 Answers0