Progress bar and dockable panels

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Posts: 98
Joined: June 8th, 2010, 2:57 pm

March 20th, 2014, 1:38 pm

I added a progress bar to a script, and everything seemed to work as expected, running it as a Window. However, as I tried to run in as a dockable panel I get an error saying I can't call update(). Am I missing something obvious here or can this not be done? Attached is an example script.

Code: Select all

function tmpScript(thisObj){
	function tmpScript_mainUI(thisObj) {

        var pal = (thisObj instanceof Panel) ? thisObj : new Window("palette", "tmp", undefined);
		if(pal != null){
			var res =
			"Group { \
			orientation: 'column', \
			alignment: ['left', 'top'], \
			one: Group { \
				orientation: 'row', \
				progressBar: Progressbar{text:'Progressbar Name', minvalue:0, maxvalue:100},\
				button: Button {text: 'Button', size: ['120', '25']}, \
				} \
			pal.grp = pal.add(res);
			pal.resizing = pal.onResize = function () {this.layout.resize()}; = function () {
			return pal;
			} // if (pal != null) {
		} // function tmpScript_mainUI(thisObj) {
	function example(pal){
		var min = 0;
		var max = 1000; = min; = max;
		for(var i = min; i<=max;i++){ = i;
		alert("Done! I will now reset the progress bar."); = 0
		} // function example(pal){
	// Run main UI.
	var myPalette = tmpScript_mainUI(thisObj);
	if (myPalette != null && myPalette instanceof Window) {;

	} // function tmpScript(thisObj){

// Run tmpScript.
Posts: 98
Joined: June 8th, 2010, 2:57 pm

March 31st, 2014, 4:50 am

I still haven't found a solution for this. Maybe someone knows of an example script that could point me in the right direction?
Posts: 4
Joined: August 1st, 2012, 5:22 pm

April 3rd, 2014, 7:14 pm

Hey Simma -

The unexpected behavior is happening because the Window object has an update() method, but the Panel object does not. So when you run as a Window, everything is fine - but when you load your script as a dockable Panel, you lose the update() method.

The good news is that you don't need to use update() at all when running as a Panel. You can test this in your script by changing your loop to this:

Code: Select all

for(var i = min; i<=max;i++){ = i;
         $.sleep(1); // Wait a little between each loop to show the progress bar changing
If you need to run your script in both situations, you could prototype a dummy update() method into the Panel object to avoid the error, by putting this at the top of your script:

Code: Select all

Panel.prototype.update = function() {};

Alternatively you could test for what type of object you are in and handle each case individually

Code: Select all

if( pal instanceof Window ){

Good Luck!
Chris Kelley
Posts: 98
Joined: June 8th, 2010, 2:57 pm

April 8th, 2014, 3:04 pm

Thanks for your reply Chris!

I've tested you suggestion and it does indeed work. However, the progress bar isn't updating for each value, it jumps from min to max value as it's finished. Is this the expected behavior? I've tried longer sleeps, but it had no effect. I'm running CC on Windows.

Post Reply