EasyManua.ls Logo

Adobe 0046100128056 - InDesign - Mac - Working with Scriptui; Creating a Progress Bar with Scriptui

Adobe 0046100128056 - InDesign - Mac
209 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
CHAPTER 7: User Interfaces Working with ScriptUI 116
function myMakeDocument(myString, myPointSize, myParagraphAlignment,
myVerticalJustification){
//Create a new document.
var myDocument = app.documents.add();
with(myDocument){
viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
var myPage = pages[0];
with(myPage){
//Create a text frame.
var myTextFrame = pages.item(0).textFrames.add();
with(myTextFrame){
//Set the geometric bounds of the frame using the "myGetBounds" function.
geometricBounds = myGetBounds(myDocument, myPage);
//Set the contents of the frame to the string you
//entered in the dialog box.
contents = myString;
//Set the alignment of the paragraph.
texts.item(0).justification = myParagraphAlignment;
//Set the point size of the text.
texts.item(0).pointSize = myPointSize;
//Set the vertical justification of the text frame.
textFramePreferences.verticalJustification = myVerticalJustification;
}
}
}
}
Working with ScriptUI
JavaScripts can make create and define user-interface elements using an Adobe scripting component
named ScriptUI. ScriptUI gives scripters a way to create floating palettes, progress bars, and interactive
dialog boxes that are far more complex than InDesigns built-in
dialog object.
This does not mean, however, that user-interface elements written using Script UI are not accessible to
users. InDesign scripts can execute scripts written in other scripting languages using the method.
Creating a progress bar with ScriptUI
The following sample script shows how to create a progress bar using JavaScript and ScriptUI, then use the
progress bar from another script (for the complete script, see ProgressBar):
#targetengine "session"
//Because these terms are defined in the "session" engine,
//they will be available to any other JavaScript running
//in that instance of the engine.
var myMaximumValue = 300;
var myProgressBarWidth = 300;
var myIncrement = myMaximumValue/myProgressBarWidth;
myCreateProgressPanel(myMaximumValue, myProgressBarWidth);
function myCreateProgressPanel(myMaximumValue, myProgressBarWidth){
myProgressPanel = new Window('window', 'Progress');
with(myProgressPanel){
myProgressPanel.myProgressBar = add('progressbar', [12, 12,
myProgressBarWidth, 24], 0, myMaximumValue);
}
}

Table of Contents

Related product manuals