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

How close a Dialog?

Enthusiast ,
Jul 14, 2016 Jul 14, 2016

Current i show a dialog of Indesign:

oIndd.DoScript ( "var range = new Window (" "dialog" "," "test" ", [200, 200 680, 325] {resizeable: false}); this.palette.show ();", 1246973031)

Can i call a other script to close that dialog ?

TOPICS
Scripting
2.3K
Translate
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
Participant ,
Jul 15, 2016 Jul 15, 2016

Hi daitranthanhoa,

Take a look in the object model viewer at the documentation for the Window constructor. You can find it in the object model viewer by choosing "ScriptUI Classes" under the Browser area, then "Constructor" under Types, then "Window (type, title, bounds, properties)" under Properties and Methods.

You'll find documented there that creating a Window with the type "dialog" (as you do in your script) creates a modal window - control won't return to your script until the user closes the dialog.

Instead, create is at type "palette".

Your script is also missing some commas and doesn't compile. I'm also not sure what context you're calling the script from. Here's a sample script that works:

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

// show the palette

range.show();

// do whatever you need to do

alert("Hellow world!");

// close the palette

range.close(); // can also hide() if you want the palette to retain its state

Lawrence

Translate
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
Enthusiast ,
Jul 19, 2016 Jul 19, 2016

i want close a dialog , not palette.

Translate
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
Participant ,
Jul 19, 2016 Jul 19, 2016

Hi,

It's not a palette like an InDesign palette. It will look exactly like a dialog, but it won't be modal. Do you actually need the dialog to be modal? If so, then Loic's last suggestion of adding event handlers is a good route to follow.

However, if all you want is a non-modal dialog, pass "palette" to the Window constructor, and you'll get a non-modal dialog.

Lawrence

Translate
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
Enthusiast ,
Jul 19, 2016 Jul 19, 2016

i use Global value, but it show error: For modal dialog or warning is active, you can not process the requested operation

When call: oDialog.Destroy()

Translate
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
People's Champ ,
Jul 19, 2016 Jul 19, 2016

If you are using a modal dialog, I have no idea how you can run a separate script. You might have wanted to mean a secondary function ?

in this case, you can either choose to call w.close() or btn.notify()

var main = function() {

  var w = new Window('dialog');

  var closeBtn = w.add('button',undefined,"w.close()");

  closeBtn.onClick = function() {

  w.close();

  };

  var btn = w.add('button',undefined,"closing w through external func");

  btn.onClick = function() {

  pleaseClose(w);

  }

  var btn2 = w.add('button',undefined,"closing w through external func & btn.notify()");

  btn2.onClick = function() {

  pleaseCloseViaNotify(closeBtn);

  }

  w.show();

}

function pleaseClose(w) {

  w.close();

}

function pleaseCloseViaNotify(btn){

  btn.notify('onClick');

}

main();

But you are probably overcomplicating stuff here. Just keep track of your w object and it should be fine.

Translate
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
Enthusiast ,
Jul 19, 2016 Jul 19, 2016
LATEST

Current i using COM adobe in VB.net

I using a Thread, to show dialog,

So i still can process some functions when dialog opening.

So After process, i want close this dialog.

Translate
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
People's Champ ,
Jul 18, 2016 Jul 18, 2016

Getting an external script to close a dialog from a different one implies to have them evolve in the same script engine.

Script 1:

#targetengine "myWindow"

//The window object needs to be globally exposed somehow

var w = new Window();

Script 2:

#targetengine "myWindow"

w.close();

HTH

Loic

Translate
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