Adobe 65009333 Scripting Guide - Page 59

Working with ScriptUI

Page 59 highlights

User Interfaces Working with ScriptUI 59 //Display the dialog box. if(myDialog.show() == true){ var myParagraphAlignment, myString, myPointSize, myVerticalJustification; //If the user didn't click the Cancel button, //then get the values back from the dialog box. //Get the example text from the text edit field. var myString = myTextEditField.editContents //Get the point size from the point size field. var myPointSize = myPointSizeField.editValue; //Get the paragraph alignment setting from the radiobutton group. if(myRadioButtonGroup.selectedButton == 0){ myParagraphAlignment = Justification.leftAlign; } else if(myRadioButtonGroup.selectedButton == 1){ myParagraphAlignment = Justification.centerAlign; } else{ myParagraphAlignment = Justification.rightAlign; } var mySwatchName = mySwatchNames[mySwatchDropdown.selectedIndex]; //Remove the dialog box from memory. myDialog.destroy(); //Now create the document and apply the properties to the text. var myDocument = app.documents.add(); with(myDocument.stories.item(0)){ //Set the contents of the story 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 fill color of the text. texts.item(0).fillColor = myDocument.swatches.item(mySwatchName); } } else{ myDialog.destroy() } 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 InCopy's built-in dialog object. This does not mean, however, that user-interface elements written using Script UI are not accessible to users. InCopy scripts can execute scripts written in other scripting languages using the method.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

User Interfaces
Working with ScriptUI
59
//Display the dialog box.
if(myDialog.show() == true){
var myParagraphAlignment, myString, myPointSize, myVerticalJustification;
//If the user didn't click the Cancel button,
//then get the values back from the dialog box.
//Get the example text from the text edit field.
var myString = myTextEditField.editContents
//Get the point size from the point size field.
var myPointSize = myPointSizeField.editValue;
//Get the paragraph alignment setting from the radiobutton group.
if(myRadioButtonGroup.selectedButton == 0){
myParagraphAlignment = Justification.leftAlign;
}
else if(myRadioButtonGroup.selectedButton == 1){
myParagraphAlignment = Justification.centerAlign;
}
else{
myParagraphAlignment = Justification.rightAlign;
}
var mySwatchName = mySwatchNames[mySwatchDropdown.selectedIndex];
//Remove the dialog box from memory.
myDialog.destroy();
//Now create the document and apply the properties to the text.
var myDocument = app.documents.add();
with(myDocument.stories.item(0)){
//Set the contents of the story 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 fill color of the text.
texts.item(0).fillColor = myDocument.swatches.item(mySwatchName);
}
}
else{
myDialog.destroy()
}
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 InCopy’s built-in
dialog
object.
This does not mean, however, that user-interface elements written using Script UI are not accessible to
users. InCopy scripts can execute scripts written in other scripting languages using the
method.