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

Create popup warning that autocloses

Explorer ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

Hi

I'm trying to pop up a warning dialog for 2 seconds then have it close.

The following code works:

var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});  

w.show(); 

alert("hi");

w.close();

but obviously doesn't autoclose

var w = new Window ("palette","test", [200, 200, 680, 325], {resizeable: false});  

w.show(); 

 

//delay(2);

$.sleep(2000);

 

w.close();

function delay(prmSec){

  prmSec *= 1000;

  var eDate = null;

  var eMsec = 0;

  var sDate = new Date();

  var sMsec = sDate.getTime();

  do {

  eDate = new Date();

  eMsec = eDate.getTime();

  } while ((eMsec-sMsec)<prmSec);

  }

using either delay or sleep the palette only shows up occasionally (every third run of the script...)

1) any idea WHY it doesn't show up reliably?

2) is there a better way to make a popup?

thanks

TOPICS
Scripting

Views

1.2K

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
Guide ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

If i tested in Extendscript then it work good..

Screen Shot 2017-04-28 at 6.19.54 PM.png

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
Explorer ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

I know. But in Indesign it doesn't.

(I'm using CC2015 on a mac in case that's part of the problem)

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
Community Expert ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

Hi,

did you run it from the ESTK addressing InDesign?

Do not run it from the ESTK.
Run it by double-click from InDesign's Scripts panel.

Another example that is working for me with my German InDesign CC 2017.1 on German Mac OSX 10.10.5
( started from the Scripts panel… )

var dlog = new Window("palette");

dlog.size = [320,100];

dlog.add("statictext", undefined , "We are closing in 2 seconds.");

dlog.show();

// Have a nap:

$.sleep(2000);

// Closing the dialog:

dlog.close();

Regards,
Uwe

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
Explorer ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

I was running it from InDesign.

Your code doesn't work either... it executes -- but the palette doesn't show up.

If I put an alert before the sleep it shows up immediately. I'm suspecting some redraw issue with ID

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
Explorer ,
Apr 28, 2017 Apr 28, 2017

Copy link to clipboard

Copied

adding a .update() before the sleep solves the problem...

Reading the discussion about progress bars it seems it's an OSx/ID bug

Thanks

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
Community Expert ,
Apr 30, 2017 Apr 30, 2017

Copy link to clipboard

Copied

akiva_atwood  wrote

I was running it from InDesign.

Your code doesn't work either... it executes -- but the palette doesn't show up.

If I put an alert before the sleep it shows up immediately. I'm suspecting some redraw issue with ID

akiva_atwood  wrote

adding a .update() before the sleep solves the problem...

Hi Akiva,

just tested with InDesign CC 2015.4.1 and CS6 8.1.0 as well.
My code is running ok. The "palette" type of Window is showing up and vanishes after the $.sleep() period.

For me the update() is not necessary but I guess it would not hurt…

What is your OSX version?
Mine is 10.10.5.

Maybe there are other things involved that makes it necessary to do an update() for you?

Thanks,
Uwe

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
Explorer ,
Apr 30, 2017 Apr 30, 2017

Copy link to clipboard

Copied

Hi Uwe

I'm running 10.12.4 -- on an airMac so I don't have a GPU (according to ID) with CC2015

CS6 works fine without the update()

I've noticed other graphic glitches with the last update to CC2015 -- text vanishes on the screen, and I have to force a redraw to see it again)

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
Guide ,
May 03, 2017 May 03, 2017

Copy link to clipboard

Copied

Thanks for reporting these issues.

So I've just added the update() trick in IdExtenso's messaging API.

IdExtenso/$$.messaging.jsxinc at master · indiscripts/IdExtenso · GitHub

By the way, does anyone actually understand the purpose of Window.update()? I mean, the way it should theoretically work and the context from which it should theoretically be invoked. Although documented, this method remains very obscure to me.

@+

Marc

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
Community Expert ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

LATEST

@akiva_atwood said: "I've noticed other graphic glitches with the last update to CC2015 -- text vanishes on the screen, and I have to force a redraw to see it again)"

 

Hi @akiva_atwood ,

just tested the "palette" type of window without using update() on Windows 10.

Ran the script from InDesign's Scripts panel. No issue with my German InDesign CS6 version 8.1.0 or InDesign 2023 version 18.1.0.51.

 

#targetengine autoCloseAlert

var sleepPeriodInSeconds = 2;
var sleepPeriodAsString = " " + sleepPeriodInSeconds + " ";
 
var dlog = new Window("palette"); 
dlog.size = [320,100]; 
dlog.add("statictext", undefined , "We are closing in"+ sleepPeriodAsString +"seconds.");
dlog.show();

// Is that necessary? :
//~ dlog.update();
// Perhaps on some versions of macOS together with some specific versions of InDesign?

// Have a nap:
$.sleep(sleepPeriodInSeconds * 1000);

// Closing the dialog: 
dlog.close();

 

Regards,
Uwe Laubender
( Adobe Community Expert )

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