ScriptUI buttons don't allow pages to be added
Greetings again,
I'm making good progress on my project, which I'll share once done.
It'll take time, but with help I'll get through it.
The simple code to add a simple page works fine but if I wrap that code into a function called by the onClick event of a button it fails in ExtendScript (all latest).
Anyone can try the code below just to see if I'm nuts or what?
#target "InDesign"
var dialog = new Window("dialog");
dialog.text = "Dialog";
dialog.orientation = "column";
dialog.alignChildren = ["center","top"];
dialog.spacing = 10;
dialog.margins = 16;
var btn = dialog.add("button", undefined, undefined, {name: "btn"});
btn.text = "No page for you";
var doc;
var pages;
app.documentPreferences.properties = {pageWidth:1.625, pageHeight:9.25}
doc = app.documents.add();
function add1page(){ pages = app.activeDocument.pages.add();}
btn.onClick = function() {add1page();};
dialog.show();
main();
function main(){}
Thank you kindly, and also, of course, Health and Happiness in this new year! 🙂
Antoine
