Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Possible palette close bug

Berater ,
Jul 17, 2009 Jul 17, 2009

I've got a palette in PSCS4 with a progress bar that won't close.

I have an onClose method that logs calls and returns 'true' so I know the palette is receiving the 'close' call, it's just not closing the palette.

If I remove my onClose method, the same thing happens.

This does not happen in PSCS3.

Has anybody else seen similar behavior?

-X

THEMEN
Aktionen und Skripte
1.1K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Adobe
Guru ,
Jul 18, 2009 Jul 18, 2009

Below is a script I found in my notes. I'm not sure who wrote it, but it does show a progress bar with a close button that works with CS4 ( at least on my system )

//
// createProgressWindow
//   title     the window title
//   min       the minimum value for the progress bar
//   max       the maximum value for the progress bar
//   parent    the parent ScriptUI window (opt)
//   useCancel flag for having a Cancel button (opt)
//   
//   onCancel  This method will be called when the Cancel button is pressed.
//             This method should return 'true' to close the progress window
//
function createProgressWindow(title, min, max, parent, useCancel) {
  var win = new Window('palette', title);
  win.bar = win.add('progressbar', undefined, min, max);
  win.bar.preferredSize = [300, 20];

  win.parent = undefined;

  if (parent) {
    if (parent instanceof Window) {
      win.parent = parent;
    } else if (useCancel == undefined) {
      useCancel = parent;
    }
  }

  if (useCancel) {
    win.cancel = win.add('button', undefined, 'Cancel');
    win.cancel.onClick = function() {
      try {
        if (win.onCancel) {
          var rc = win.onCancel();
          if (rc || rc == undefined) {
            win.close();
          }
        } else {
          win.close();
        }
      } catch (e) {
        alert(e);
      }
    }
  }

  win.updateProgress = function(val) {
    var win = this;
    win.bar.value = val;
    // recenter the progressWindow if desired
    // win.center(win.parent);
    win.show();
    win.hide();
    win.show();
  }
  win.center(win.parent);
  return win;
};

var arry = ['a','b','c','d'];

  var progressWindow = createProgressWindow("Progress...",
                                            0, arry.length, true);
  progressWindow.isDone = false;
  progressWindow.onCancel = function() {
    this.isDone = true;
    return true;  // return 'true' to close the window
  }

  try {
    for (var i = 0; i < arry.length; i++) {
      if (progressWindow.isDone) {
        break;
      }
      progressWindow.text = ("Processing element " + (i+1) + " of " + arry.length + "...");
      progressWindow.updateProgress(i);

       $.sleep(5000)
       alert(arry);
       
    }
  } catch (e) {
    alert(e);

  } finally {
    progressWindow.close();
  }
$.sleep(5000);
alert('done');

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Berater ,
Jul 19, 2009 Jul 19, 2009
Below is a script I found in my notes. I'm not sure who wrote it, but
it does show a progress bar with a close button that works with CS4 (
at least on my system ).

Heh, heh. That's actually my code. Or, at least, a previous version. I added an 'onClose' handler and at 'isDone' state variable so that I could break loops when the palette was canceled or closed.

Given that the code is working _without_ the onClose handler, I have a good idea where the problem is.

Thanks much. I'll post back when I get this nailed down.

-X

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Nov 03, 2010 Nov 03, 2010
AKTUELL

I've tried out the progress bar in CS2 and it seems to run fine - although the progress window update doesn't seem to happen until the later happens. See piccy.

Is this a CS version issue or something else. Incidentally whilst on the subject are there any docs about compatibility and backward compatibility of scripts. Obviously there are new function calls that have been indroduced and can't be used in older versions but I was wondering if someones'a actually noted them down somewhere.

Cheers

progress_bar.png

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines