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

How do we close the dialog box programmatically without click button using extendscript

Explorer ,
Oct 09, 2024 Oct 09, 2024

Hi Folks,
Is there any possibilities to close dialog box programmatically without click button.

Sample code:

var dlg = new Window('dialog', 'Custom Dialog');
dlg.add('statictext', undefined, 'This is a custom alert!');

var closeBtn = dlg.add('button', undefined, 'Close', {name: 'ok'});
closeBtn.onClick = function() {
dlg.close(); // Programmatically close the dialog
}

dlg.show();
TOPICS
Bug , How-to , Scripting , Tools
483
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
Adobe
Community Expert ,
Oct 09, 2024 Oct 09, 2024

Hi @Jothi Sankar Anand S can you give us a bit more idea of what you want to achieve? You sample code already shows how to programmatically close the dialog:

dlg.close();

You don't have to put that in the button's onClick event. You can use it anywhere that you have a valid reference to a visible dialog window.

 

What did you have in mind?

- Mark

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
Explorer ,
Oct 09, 2024 Oct 09, 2024

I'm expecting to close without click event dlg.close(); this one within the onClick event so its not closing automattically like after 3 second

closeBtn.onClick = function() {
dlg.close(); // Programmatically close the 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
Community Expert ,
Oct 09, 2024 Oct 09, 2024

A silly example:

var dlg = new Window('dialog', 'Custom Dialog');
dlg.add('statictext', undefined, 'Type "close" to finish!');

var field = dlg.add('edittext {text:"open", alignment:["fill","center"]}');

field.onChanging = function () {
    if ('close' === this.text)
        dlg.close();
}

dlg.show();
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
Explorer ,
Oct 09, 2024 Oct 09, 2024

HI @m1b 
Actually dont touch any button or anything to close modal. It will close after some time like 3 sec or anything.

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
Community Expert ,
Oct 09, 2024 Oct 09, 2024

Ah, I see. I'm pretty sure ScriptUI doesn't allow for anything like that. It only spawns mouse and keyboard events, not time events. Sorry.

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
Explorer ,
Oct 09, 2024 Oct 09, 2024
LATEST

Thanks for the update @m1b 

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