-
1. Re: JS CS3 Simple Dialog to change doc starting page.
Kasyan Servetsky Apr 19, 2009 11:09 PM (in response to John.Kordas)Hi John,
You don't need to close and reopen the window. Instead of dialog use 'palette' type of the window and run the script in a persistent engine, e.g. #targetengine "session".
Kasyan
#targetengine "session"
var myDialog = new Window('palette','Starting Pg No');
myDialog.dPgNo = myDialog.add('panel',undefined,'File details');
myDialog.dPgNo.alignChildren = 'left';
myDialog.dPgNo.myPgNo = myDialog.dPgNo.add('group');
myDialog.dPgNo.myPgNo.myGroup = myDialog.dPgNo.myPgNo.add('group');
myDialog.dPgNo.btnGroup = myDialog.dPgNo.add('group');
with (myDialog.dPgNo){
myPgNo.myGroup.orientation = 'column';
myPgNo.myGroup.alignChildren = 'right';
myPgNo.myGroup.preferredSize = [90,15];
myPgNo.myGroup.st = myPgNo.myGroup.add('statictext',undefined,'Your Doc starting page is:');
myPgNo.et = myPgNo.add('edittext', undefined, app.activeDocument.pages[0].name)
btnGroup.btn = btnGroup.add('button', undefined, 'Update');
btnGroup.alignment = 'right';
}
myDialog.show();myDialog.dPgNo.btnGroup.btn.onClick = function() {
var myPagestart = myDialog.dPgNo.myPgNo.et.text;
if (app.activeDocument.pages[0].name != myPagestart){
app.activeDocument.pages[0].appliedSection.continueNumbering = false;
app.activeDocument.pages[0].appliedSection.pageNumberStart = parseInt(myPagestart);
app.activeDocument.pages[0].appliedSection.sectionPrefix = "";
alert("Your document start page has been changed to "+myPagestart+".");
}
} -
2. Re: JS CS3 Simple Dialog to change doc starting page.
John.Kordas Apr 19, 2009 11:16 PM (in response to Kasyan Servetsky)Thanks Kasyan,
For some reason when I tried to run the script from ESTK I kept getting an error could not run session. I ran it form ID and it worked fine. I then went back to ESTK and now it works. Don't know what happened there but it's working now.
Much appreciated.
-
3. Re: JS CS3 Simple Dialog to change doc starting page.
Harbs. Apr 19, 2009 11:25 PM (in response to John.Kordas)In scripting, modal dialogs can not make any changes until they are
closed. The way I handle these situations when I want modal dialogs is
save the settings to a variable, and then after the dialog is closed I
make the changes.
Something like this:
if(myDialog.show()){ if(settings){ doSomething(settings.setting1); doSomethingElse(settings.setting2); }Harbs
-
4. Re: JS CS3 Simple Dialog to change doc starting page.
Kasyan Servetsky Apr 19, 2009 11:35 PM (in response to John.Kordas)For some reason when I tried to run the script from ESTK I kept getting an error could not run session.
Create a persistent engine at start up: e.g. place a scipt containing #targetengine "session" into 'Adobe InDesign CS3\Scripts\Startup Scripts' folder.
For example:
#targetengine "session"
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
-
5. Re: JS CS3 Simple Dialog to change doc starting page.
John.Kordas Apr 19, 2009 11:59 PM (in response to Kasyan Servetsky)Thanks Harbs,
I thought that might have been the case and I tried to pass them to a variable but I must of got it wrong somehow. I may have even try to pass them to a function which is probably why it did not work.
Kasyan I think I may have caused the error. I found a post by Harbs a while back where he had a similar line as yours to allow an disallow UserInteractionLevels.
The only thing about the palette option is that it does not allow you to run it in ESTK. Over the last few days of getting my head around ScriptUI I found the best time saver was that I could run the dialog in ESTK to see the layout and not have to go back and forth between ID and ESTK. The more I get to know ScriptUI I really do not see myself going back to the classic dialogs.
-
6. Re: JS CS3 Simple Dialog to change doc starting page.
Kasyan Servetsky Apr 20, 2009 7:14 AM (in response to John.Kordas)The only thing about the palette option is that it does not allow you to run it in ESTK.
It does allow you to do this. But you should run the script in a persistent engine – if you run it in the ‘main’ (not persistent) engine the window will flash open before immediately closing. But so that to be able to run the scriptin it, you have to create it first: you can do it by start up script, as I showed you in my previous post – the custom engine will be created every time you (re)start InDesign, or by running the script from the scripts panel.
As to the UserInteractionLevels string, it is just an example of a start up script – it’s not obligatory in your case.
Kasyan



