Script UI adding additional buttons

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
adamghering
Posts: 22
Joined: April 2nd, 2010, 1:14 am

So I am trying to learn this myself and using the examples in the script reference

I am using this snippet of code in the ScriptUI panels folder to generate a dockable panel with a button.

function createUI(thisObj) {
var myPanel = thisObj ;
myPanel.add("button", [10, 10, 100, 30], "Tool #1");
return myPanel;
}
var myToolsPanel = createUI(this);

I get what it is doing...I have a feeling that this is not the best way to generate a button....
If I try to use the same code to add another button it doesn't do anything.

How do I add multiple buttons?

Thanks
Adam Ghering
Compositing Supervisor
Legend Films inc.
2D/3D Stereo Conversion
User avatar
vfxman
Posts: 49
Joined: February 23rd, 2007, 7:00 pm
Location: California
Contact:

This is what I use when making my scripts. Replace all the 'NAMEONE', 'NAMETWO' and 'NAMETHREE' (including the single quotation marks too) with a your own names. Going this route will not auto size or auto space any UI elements, but will allow you to make multiple buttons. I included some sample code snippets for a few common UI elements below the "//SAMPLE UI CODE" comment. If you copy and paste this into ExtendScript Toolkit and run it, you'll see what this UI looks like. Hope it helps.

Code: Select all

{
function 'NAMEONE'(thisObj) {
	function 'NAMETWO'_buildUI(thisObj) {
		var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "", [100, 100, 300, 280]);//

		//SAMPLE UI CODE
		var buttonOne = myPanel.add("button", [10,10,180,30], "Name Of Your Button");
		var checkboxOne = myPanel.add("checkbox", [10,35,180,55], "Name Of Your Checkbox");
		var radiobuttonOne = myPanel.add("radiobutton", [10,60,180,80], "Name Of Your RadioButton");
		var ddList = new Array("Item one", "Item two", "Item three", "Item four");
		var dropdownlistOne = myPanel.add("dropdownlist", [10,85,180,105], ddList);
			dropdownlistOne.selection = 0;
		var statictextOne =  myPanel.add("statictext", [10,110,180,130], "Your Text");
		var edittextOne =  myPanel.add("edittext", [10,140,180,160], "Your Text");

		return myPanel;
	} //END OF PANEL CREATION



///	THIS WILL CHECK IF PANEL IS DOCKABLE OR FLAOTING WINDOW	—————————————
	var 'NAMETHREE'Pal = 'NAMETWO'_buildUI(thisObj);
	if (('NAMETHREE'Pal != null) && ('NAMETHREE'Pal instanceof Window)) {
		'NAMETHREE'Pal.center();
		'NAMETHREE'Pal.show();
		}
	}
	'NAMEONE'(this);
}
adamghering
Posts: 22
Joined: April 2nd, 2010, 1:14 am

Amazing thanks man...

had to alter some of the script to get it working but thats probably due to my inexperience or understanding of what you wrote....but I definitely have a handle on the whole multiple button thing

I am sure this is really generic but this is what I ended up with.

function NAMETWO_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "", [100, 100, 300, 280]);//

//SAMPLE UI CODE
var buttonOne = myPanel.add("button", [10,10,180,30], "Name Of Your Button");
var checkboxOne = myPanel.add("checkbox", [10,35,180,55], "Name Of Your Checkbox");
var radiobuttonOne = myPanel.add("radiobutton", [10,60,180,80], "Name Of Your RadioButton");
var ddList = new Array("Item one", "Item two", "Item three", "Item four");
var dropdownlistOne = myPanel.add("dropdownlist", [10,85,180,105], ddList);
dropdownlistOne.selection = 0;
var statictextOne = myPanel.add("statictext", [10,110,180,130], "Your Text");
var edittextOne = myPanel.add("edittext", [10,140,180,160], "Your Text");

return myPanel;
} //END OF PANEL CREATION
NAMETWO_buildUI(this);

Now on to more stuff... I am going to try to get the buttons to create dynamically off of the list of scripts available in a folder

thanks again.
Adam Ghering
Compositing Supervisor
Legend Films inc.
2D/3D Stereo Conversion
User avatar
vfxman
Posts: 49
Joined: February 23rd, 2007, 7:00 pm
Location: California
Contact:

If that works better for you then great. Are you looking to build a script launcher UI like "Launch Pad" to launch scripts with a single click?

http://www.adobe.com/cfusion/exchange/i ... id=1242019
adamghering
Posts: 22
Joined: April 2nd, 2010, 1:14 am

Probably something like that...learning as I go...I just wish there was something more comprehensive like the mel script command reference or the unreal scripting wiki...
Adam Ghering
Compositing Supervisor
Legend Films inc.
2D/3D Stereo Conversion
User avatar
vfxman
Posts: 49
Joined: February 23rd, 2007, 7:00 pm
Location: California
Contact:

I here ya on that. I learned just like you, dissecting other scripts and scouring the web for bits and pieces. I asked Todd Kopriva (of Adobe) about the possibility of a CS5 updated scripting guide and his answer was, yes. No mention of eta though. :) Hopefully soon.
Post Reply