Page 1 of 1
I just want a button that says "Go!" and I cant get it
Posted: February 6th, 2009, 2:28 am
by Brandon_M
Can someone give me some bare bones code I could use that creates a button in my dockable window that when pressed will initiate the "script" ?
I am able to get the button up but have no idea how to tell it what to do when its clicked.
Still learning, but cant find ANYTHING on the ScriptUI stuff.
Thanks guys!
Re: I just want a button that says "Go!" and I cant get it
Posted: February 7th, 2009, 11:26 am
by Yenaphe
This piece of code should help you.
It creates a panel "YourPanel", with a button that execute the script linked to them in the "addscriptbutton" fonction. This code is based on one of the sample script provided with AE.
Code: Select all
{
function onScriptButtonClick()
{
var scriptFile = new File(this.currentDirectory+this.scriptFileName);
scriptFile.open();
eval(scriptFile.read());
scriptFile.close();
}
function addScriptButton(palette, buttonRect, buttonLabel, buttonCurrentDirectory, buttonScriptName)
{
var newButton = palette.add("button", buttonRect, buttonLabel);
newButton.scriptFileName = buttonScriptName;
newButton.currentDirectory = buttonCurrentDirectory;
newButton.onClick = onScriptButtonClick;
return newButton;
}
function createUI(thisObj)
{
var myPanel = ( thisObj instanceof Panel) ? thisObj : new Window("palette", "Your Panel Name", undefined, {resizeable:true});
var Your_Button_Name = addScriptButton(myPanel,[topleft_x, topleft_y, bottomright_x, bottomright_y], "Your_Button_Label", "Your_Script_Directory", "Your_Script_Filename");
//You can add how many buttons you want
return myPanel;
}
var YourPanel = createUI(this);
if (YourPanel instanceof Window) YourPanel.show();
}
Enjoy
/Seb
Re: I just want a button that says "Go!" and I cant get it
Posted: February 7th, 2009, 2:10 pm
by Brandon_M
Oh great! Thanks I will go through it now.