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!!!!
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();
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();
Copy link to clipboard
Copied
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!