Skip to main content
Legend
October 18, 2012
Question

How to reliably close a palette window

  • October 18, 2012
  • 1 reply
  • 823 views

Hi,

I'm trying to figure out how to positively close a palette window that has both an X in the upper right corner and a Close button. The reason is that I want to use the Window.find() method to determine if the window already exists when someone attempts to launch it, such that duplicate palettes cannot be produced, for example

var graphicUtilsDlg = Window.find ("palette", "My Graphic Utilities");

if(graphicUtilsDlg != null) return;

So, I define this palette as graphicUtilsDlg, but before I do, I call the method above to see if a current instance exists.

On the palette, I have a Close button tied to the following callback:

graphicUtilsDlg.closeBtn.onClick = function()

{

    graphicUtilsDlg.close();

    graphicUtilsDlg = null;

};

...and the following callback which is invoked by the close() method above and also when the X is clicked:

graphicUtilsDlg.onClose = function()

{

    graphicUtilsDlg = null;

};

It works fine when I click the Close button. The window closes and the next attempt to open it works normally. However, it does not work properly when I click the X button. It takes two attempts before the window opens again. Somehow, the find() method is returning an object the first time, but not the second time.

Anyway, I know this is a bit windy and complex, but does anyone have any expertise here?

Thanks,

Russ

This topic has been closed for replies.

1 reply

Inspiring
October 25, 2018

Hi Russ,

I do the same thing as you. And I have the same problem too, if i close with "X", Ineed to open twice to have my palette back.

Did you find a why to avoid that?

Russ WardAuthor
Legend
October 25, 2018

Hi philippep2776167, wow this is a very old thread, hard to remember! I don't think I ever found a solution, so I just used the workaround that I mentioned. Then, I never thought about it again.

Russ