Copy link to clipboard
Copied
Hi all !
I'm doing a project in HTML5 for version Photoshop CC2014. Want to hide from users the contents of the script file, for this was transformed it into Jsxbin. How to call a script on the click of a button ? I would like using include to insert the contents of all files with saptami in the main file.
Nothing immediatelly pops into my eye..
Copy link to clipboard
Copied
You might have to describe the case a bit more. Generally if you need an UI, you need to create a HTML panel (checkout the tutorial series by Davide HTML Panels | Photoshop, etc.). From there you can execute the .jsxbin (e.g. target currently opened doc/selected layer). You can also have multiple .jsxbin files and pass data between HTML and Photoshop to make a more detailed UI.
Copy link to clipboard
Copied
thanks for the quick reply.
I created a test project in Breckets , on the panel there is positioned the button id="test_button". When clicking on it calls the function. In the function using alert() to check form settings. All true, but this script does not work
(function () {
'use strict';
var csInterface = new CSInterface();
function init() {
themeManager.init();
$("#test_button").click(function () {//--------------------------- this button click
alert("start");
var lDir = "/jsx/bin/";
var fileName = "alert.jsx";
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) ;
var lPath = extensionRoot.substr(0,extensionRoot.length-1)+lDir;
alert(lPath.substr(0,30)+"\n"+lPath.substr(31));
csInterface.evalScript('$.evalFile("' + lPath +fileName + '")');
});
}
init();
}());
Example from Davide
Copy link to clipboard
Copied
Nothing immediatelly pops into my eye..
Copy link to clipboard
Copied
Thanks, searched and found 🙂 the fact that for some reason the path to the directory that you created Breckets has at the end of a single quotation mark! I thought it was an unnecessary sign and remove it 🙂 ... a simple script with a call to ALERT(123) and jsx works and jsxbin. Old complicated script with window creation and heaps of controls works in Photoshop CC 2014 from the Extended Script Tool, but not working when called from the panel. I will try to repeat it in small pieces.
Copy link to clipboard
Copied
it is possible to create window in HTML and write scripts in JS ?
Copy link to clipboard
Copied
Not sure if I got this, but the button you created is in HTML and code you wrote is JS. The panel is a webpage and can use pretty much all HTML/JS libraries.In your "JSX code" (one that manipulates Photoshop) there is no HTML, only ScriptUI panels/dialogs. See also my comment in How to Call a Function
Copy link to clipboard
Copied
Maybe then it is worth making a large panel (HTML), the side positioning of the controls and all the organs of the interaction with the user to place the remaining panels. Get something people a desktop app :-)
Copy link to clipboard
Copied
I think so too. In any case you have to do the HTML and it gives you much more options, so you might as well get most out of it.
Copy link to clipboard
Copied
I wanted to ask. In the click a button "Test" I was temporarily prescribed a HTML script that displays some information in a DIV="ploutput". But I don't want to clutter the JS file for the HTML language. How to do it right so in this function to call an external file with HTML markup ?
Copy link to clipboard
Copied
There's no one true answer. My way is just to capsulate it nicely, i.e. make a function like
function createButton(id, title, background_color, width) {
return '<div id="'+id+'" style="background-color:'+background_color+';width:'+width+';">'+title+'</div>'
}
(Point being that you have only one point where that html exists and you don't have to worry about it when you create it in JS)