Thursday 14 July 2016

How to make something useful in Extendscript pt. 3

From the end of Part 2 it looks like this:



We create the window, add the button, then create an onClick function for the button. To add a list instead of a button it looks similar:
var myList = myPanel.add ("listbox",[10,10,200,280]);
we just have to add the items for list directly afterwards:
myList.add ("item", 'script 01');
myList.add ("item", 'script 02');
myList.add ("item", 'script 03');
A list [the object name is listbox] uses different actions to work since it behaves differently to a button, we can use onChange and onDoubleClick. 
 myList.onDoubleClick = function () {...}
Within the "myList.onDoubleClick" function is the code for what happens on the selected list item.
if  (myList.selection.text=="script 01"){
   alert("pressed something");
};
There are two ways of doing this as well, you can use selection.text=="" and type the name of the item, or you can use selection.index==0 and that will return the first item in the list. Handy.

This example uses both those methods and creates actions for the first 2 list items:


Getting there, we have a dockable ScriptUI panel that does stuff.  The next bit of problem solving is how to apply an After Effects expression to a selected layer.

More of that in the last bit Part 4.


2 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete