Adobe 65009333 Scripting Guide - Page 61

For example, The following functions read the XML file and set up the button bar

Page 61 highlights

User Interfaces Working with ScriptUI 61 For example: text FindChangeByList /c/buttons/FindChangeByList.jsx text SortParagraphs /c/buttons/SortParagraphs.jsx The following functions read the XML file and set up the button bar: #targetengine "session" var myButtonBar; main(); function main(){ myButtonBar = myCreateButtonBar(); myButtonBar.show(); } function myCreateButtonBar(){ var myButtonName, myButtonFileName, myButtonType, myButtonIconFile, myButton; var myButtons = myReadXMLPreferences(); if(myButtons != ""){ myButtonBar = new Window('window', 'Script Buttons', undefined, {maximizeButton:false, minimizeButton:false}); with(myButtonBar){ spacing = 0; margins = [0,0,0,0]; with(add('group')){ spacing = 2; orientation = 'row'; for(var myCounter = 0; myCounter < myButtons.length(); myCounter++){ myButtonName = myButtons[myCounter].xpath("buttonName"); myButtonType = myButtons[myCounter].xpath("buttonType"); myButtonFileName = myButtons[myCounter].xpath("buttonFileName"); myButtonIconFile = myButtons[myCounter].xpath("buttonIconFile"); if(myButtonType == "text"){ myButton = add('button', undefined, myButtonName); } else{ myButton = add('iconbutton', undefined, File(myButtonIconFile)); } myButton.scriptFile = myButtonFileName; myButton.onClick = function(){ myButtonFile = File(this.scriptFile) app.doScript(myButtonFile); } } } } }

  • 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
61
For example:
<buttons>
<button>
<buttonType>text</buttonType>
<buttonName>FindChangeByList</buttonName>
<buttonFileName>/c/buttons/FindChangeByList.jsx</buttonFileName>
<buttonIconFile></buttonIconFile>
</button>
<button>
<buttonType>text</buttonType>
<buttonName>SortParagraphs</buttonName>
<buttonFileName>/c/buttons/SortParagraphs.jsx</buttonFileName>
<buttonIconFile></buttonIconFile>
</button>
</buttons>
The following functions read the XML file and set up the button bar:
#targetengine "session"
var myButtonBar;
main();
function main(){
myButtonBar = myCreateButtonBar();
myButtonBar.show();
}
function myCreateButtonBar(){
var myButtonName, myButtonFileName, myButtonType, myButtonIconFile, myButton;
var myButtons = myReadXMLPreferences();
if(myButtons != ""){
myButtonBar = new Window('window', 'Script Buttons', undefined,
{maximizeButton:false, minimizeButton:false});
with(myButtonBar){
spacing = 0;
margins = [0,0,0,0];
with(add('group')){
spacing = 2;
orientation = 'row';
for(var myCounter = 0; myCounter < myButtons.length(); myCounter++){
myButtonName = myButtons[myCounter].xpath("buttonName");
myButtonType = myButtons[myCounter].xpath("buttonType");
myButtonFileName = myButtons[myCounter].xpath("buttonFileName");
myButtonIconFile = myButtons[myCounter].xpath("buttonIconFile");
if(myButtonType == "text"){
myButton = add('button', undefined, myButtonName);
}
else{
myButton = add('iconbutton', undefined,
File(myButtonIconFile));
}
myButton.scriptFile = myButtonFileName;
myButton.onClick = function(){
myButtonFile = File(this.scriptFile)
app.doScript(myButtonFile);
}
}
}
}
}