I am trying to write a script that opens a dialog so the user can choose if colums and gutter should be adjusted. This is ment for tesing. I want to take this further later on but at the moment I am stuck with this simple task. The dialog works fine and the columns part works fine but I can’t merge it together successully. Where is my mistake?
var doc = app.activeDocument;
var selectedPage = doc.pages.item(0);
var mp = selectedPage.marginPreferences;
var dialog = new Window("dialog");
dialog.text = "Columns and Gutter";
dialog.preferredSize.width = 400;
dialog.orientation = "column";
dialog.alignChildren = ["left","top"];
dialog.spacing = 10;
dialog.margins = 16;
// GROUP1
// ======
var group1 = dialog.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","top"];
group1.spacing = 30;
group1.margins = 0;
var statictext1 = group1.add("statictext", undefined, undefined, {name: "statictext1"});
statictext1.text = "Adjust to 12 Columns, Gutter 4?";
// GROUP2
// ======
var group2 = dialog.add("group", undefined, {name: "group2"});
group2.orientation = "row";
group2.alignChildren = ["left","center"];
group2.spacing = 10;
group2.margins = [0,20,0,0];
group2.alignment = ["right","top"];
var button1 = group2.add("button", undefined, undefined, {name: "button1"});
button1.text = "Cancel";
var button2 = group2.add("button", undefined, undefined, {name: "button2"});
button2.text = "OK";
button2.onClick = function () {
// Set gutter
mp.columnGutter = 4;
// Set column count
mp.columnCount = 12;
dialog.close(1);
};
button1.onClick = function () {
dialog.close(0);
};
dialog.show();