• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Palette’s UI close button firing onClose callback multiple times

Engaged ,
Jan 12, 2016 Jan 12, 2016

Copy link to clipboard

Copied

Hi,

When doing:

palette.onClose = function() { ... }

… and then clicking on the palette’s UI close button (the small OS UI circle in top left corner), the onClose callback fires at least 20 times.

Why? Is this normal behavior?

When turning off the OS UI close button (using option closeButton: false), and creating a button instead:

palette.myCloseButton.onClick = function() { ... }

The onClick fires once and the palette window is closed.

Anyone else notice this difference? Is it just me?

I'd love to not have a close button for my palette … I'd prefer to use the OS UI close circular button (but not if it's going to fire the callback many times in a row).

Thanks!!!!

TOPICS
Scripting

Views

442

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 13, 2016 Jan 13, 2016

I did a simple test, and it only seems to be firing just once on my Mac Yosemite computer.

#target illustrator-19

function test(){

  var w = new Window("palette", "Test");

  var lbl = w.add("statictext", undefined, "Test");

  w.onClose = function(){

  alert('closed.');

  };

  w.show();

};

test();

Votes

Translate

Translate
Adobe
Valorous Hero ,
Jan 13, 2016 Jan 13, 2016

Copy link to clipboard

Copied

I did a simple test, and it only seems to be firing just once on my Mac Yosemite computer.

#target illustrator-19

function test(){

  var w = new Window("palette", "Test");

  var lbl = w.add("statictext", undefined, "Test");

  w.onClose = function(){

  alert('closed.');

  };

  w.show();

};

test();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 16, 2016 Jan 16, 2016

Copy link to clipboard

Copied

LATEST

Ack, that does work!!! Thanks for the test code Silly-V‌, I greatly appreciate it.

Here's what I was doing wrong:

palette.onClose = function() {

  $.writeln('onClose');

  palette.close();

}

Having the close(); method in there creates some sort of recursion. I just removed that line and now I only get one "onClose" callback/output to the debug console.

So, to clarify for future readers (i.e., my future self), the onClose method for a palette or window does not need to call a close() method.

Thanks again Silly-V! You rock!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines