Eclipse + extension builder 3
First I create basic folder structure for the project
css
img
lib
host
js
jsx
and call all scripts and stylesheets in index.html like this:
<head>
<script src="lib/CSInterface-4.0.0.js"></script>
<script src="lib/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="js/main.js"></script>
<!-- styles for this extension -->
<link href="css/stylesheet.css" rel="stylesheet">
<title>test</title>
</head>
opennewdocument.jsx-----------------
#target photoshop
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
//
//==================== open new document ==============
//
function opennewdocument() {
// Make
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var desc2 = new ActionDescriptor();
desc2.putString(sTID("preset"), "Clipboard");
desc1.putObject(cTID('Nw '), cTID('Dcmn'), desc2);
executeAction(cTID('Mk '), desc1, dialogMode);
};
step1(); // Make
};
//=========================================
// opennewdocument.main
//=========================================
//
opennewdocument.main = function () {
opennewdocument();
};
opennewdocument.main();
// EOF
"opennewdocument.jsx"
// EOF
Then, I put opennewdocument.jsx (above) script into jsx folder and connect it's path in the main.js file (below)
(the .jsx is converted from simple action that opens a new document)
main.js
function loadJSX() {
var csInterface = new CSInterface();
var fileName = "opennewdocument.jsx";
var extensionRoot = csInterface["getSystemPath"](SystemPath.EXTENSION) + "/jsx/";
csInterface["evalScript"]("$.evalFile(\"" + extensionRoot + fileName + "\")")
}
Then i make a button that need to open document on click like so:
<button onclick="opennewdocument()" type="button" class="new-doc"></button>
and nothing :/
