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

How to reliably close a palette window

Mentor ,
Oct 18, 2012 Oct 18, 2012

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

685

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
Explorer ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

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?

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
Mentor ,
Oct 25, 2018 Oct 25, 2018

Copy link to clipboard

Copied

LATEST

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

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