Skip to main content
Inspiring
August 7, 2016
Answered

PromptToSaveChanges / ScriptUI Default Highlighted Button

  • August 7, 2016
  • 1 reply
  • 1460 views

Hi!

For some reason when I try to close a document using SaveActions.PROMPTTOSAVECHANGES, the prompt never appears and it autosaves and closes. As a workaround, I've just built my own dialog using ScriptUI, but for some reason I can't figure out how to set the OK button to be highlighted by default like the AI prompt.

var dlg = new Window('dialog', 'Save Changes?');

dlg.orientation = 'column';

dlg.add( 'staticText', undefined, 'Save changes to ' + doc.name + ' before closing?' );

var btnGrp = dlg.add( 'group' );

var yes = btnGrp.add( 'button', undefined, 'Yes' );

var no = btnGrp.add( 'button', undefined, 'No' );

btnGrp.add( 'button', undefined, 'Cancel' );

dlg.defaultElement = yes;

dlg.show;

If you have could point me in the right direction in either, I'd really appreciate it!  Thanks!

This topic has been closed for replies.
Correct answer pixxxelschubser

no idea.

But this could be a workaround:

yes.active = true;

yes.active = false;

yes.active = true;

1 reply

pixxxelschubser
Community Expert
Community Expert
August 7, 2016

Try

yes.active = true;

And do not forget the brackets after show()

zertleAuthor
Inspiring
August 7, 2016

Thank you so much!  I don't know how I missed that!