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!
I just want a button that says "Go!" and I cant get it
Moderator: Paul Tuersley
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.
Enjoy
/Seb
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();
}
/Seb
Sébastien
http://www.yenaphe.info
http://www.yenaphe.info