Shortcut Buttons Panel: JavaScript
The first part of the Shortcut Buttons Panel is creating a JavaScript file. The JavaScript file will have a function that creates a new document in Adobe Photoshop and a function to close a document in Adobe Photoshop. The JavaScript file will be created using ExtendScript Toolkit. The result is to place the JavaScript file into the Adobe Photoshop Panels folder for the SWF file to communicate with.
Go to Shortcut Buttons Panel's JavaScript API that covers a summary of functions and scripts used.
Instructions:
- Open ExtendScript Toolkit.
- Go to File > New JavaScript.
- Copy the following JavaScript code into the new file:
- Go to File > Save As....
- Under Save As:, type in ShortcutButtons.jsx.
- Save the file into the Panels folder under the Adobe Photoshop CS5\Plug-ins\ folder located under:
- Applications for Macintosh
- Program Files for Windows
- Press Save.
- Close ExtendScript Toolkit.
function addDocument(){
app.documents.add();
}
function closeDocument(){
app.activeDocument.close();
}
Code Walkthrough: The two functions, addDocument and closeDocument, and respective code app.documents.add(); and app.activeDocument.close();, adds a new document and closes a document respectively.