-
Adding a keyboard listener to script window
Hello all,
I’m trying to write a script that will let me parent layers with nothing but the keyboard. I’ve gotten to the point where the script can change the parent of a layer, but I can’t get the script to execute without clicking a button.
I’ve read that event listeners no longer work in ExtendScripts. Is there another way to add a keyboard command onto a UI button?
var mainComp = app.project.activeItem;
var mainWindow = new Window("palette","The Parenter", undefined);var groupOne = mainWindow.add("group", undefined,"groupOne");
groupOne.orientation = "column";groupOne.add("statictext", undefined,"This script Parents your layers");
var theParent = groupOne.add("edittext", undefined, "Parent");
var firstChild = groupOne.add("edittext", undefined, "First Child");var groupTwo = mainWindow.add("group", undefined, "Buttons");
groupTwo.orientation = "row";
var startButton = groupTwo.add("button", undefined, "Parent!");
var cancelButton = groupTwo.add("button", undefined, "Cancel")startButton.onClick = function(){
app.beginUndoGroup("Parent");
doThings();
}
cancelButton.onClick = function(){
mainWindow.close();
}function doThings(){
var setParent = parseInt(theParent.text);
var setChildren = parseInt(firstChild.text);
mainComp.layer(firstChild).parent = mainComp.layer(setParent);mainWindow.close();
app.endUndoGroup("Parent");
}mainWindow.show();
mainWindow.center();
Sorry, there were no replies found.