Working With Scriptui; Creating A Progress Bar With Scriptui - Adobe 0046100128056 - InDesign - Mac Manual

Javascript
Table of Contents

Advertisement

C
7: User Interfaces
HAPTER
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){
}
}
}

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 InDesign's built-in
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);
}
}
//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 116
object.
dialog

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents