Skip to content
fabiantheblind edited this page May 4, 2016 · 3 revisions

You can create simple dialogs in InDesign. The layouting just consists of columns and rows. What is nice about it is that there are type dedicated input fields. In the example below you will see a simple dialog that has a text input field and a integer input field. If you enter a String in the integer field InDesign will warn the user about his non integer value. There are also nice features for constraining the values. You even can set the steps a value gets increased when the user hits the up and down arrows.

var diag = app.dialogs.add();
var column1 = diag.dialogColumns.add();
var txtlabel = column1.staticTexts.add({staticLabel:'Text: '});
// http://yearbook.github.io/esdocs/#/InDesign/TextEditbox
var txt = column1.textEditboxes.add(); 
var column2 = diag.dialogColumns.add();
var numlabel = column2.staticTexts.add({staticLabel:'Number: '});
// see http://yearbook.github.io/esdocs/#/InDesign/IntegerEditbox
var num = column2.integerEditboxes.add();
if(diag.show() == true){
  var numval = num.editValue;
  var numvalastxt = num.editContents;
  var txtval = txt.editContents;
  diag.destroy();
  $.writeln('numval is a ' + numval.constructor.name);
  $.writeln('numvalastxt is a ' + numvalastxt.constructor.name);
  $.writeln('txtval is a ' + txtval.constructor.name);
}
Clone this wiki locally