Skip to content
Fabian Morón Zirfas edited this page Jun 13, 2025 · 3 revisions

InDesign has aside from scriptUI (which is available in all the extendscriptable[^1]) his own engine to create dialogs. 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. Keep in mind that they are blocking. Until the user hits okay, there is no other interaction with InDesign possible.

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);
}

The following script creates a dialog with a radiobutton group.

/* global app, $*/
var diag = app.dialogs.add({
	name: "my awesome dialog",
	canCancel: true,
});
var col1 = diag.dialogColumns.add();
var radioGrp = col1.radiobuttonGroups.add();
var ctrl1 = radioGrp.radiobuttonControls.add({
	staticLabel: "selection1",
	checkedState: true,
});
var ctrl2 = radioGrp.radiobuttonControls.add({
	staticLabel: "selection2",
});

if (diag.show() === true) {
	if (ctrl1.checkedState === true) {
		$.writeln("user selected item 1");
	} else if (ctrl2.checkedState === true) {
		$.writeln("user selected item 2");
	}
	diag.destroy();
}

[^1]: Yes that sounds wired.

Home

Clone this wiki locally