Copy link to clipboard
Copied
Recently I have created a Photoshop Panel for Photoshop CC 2018 specifically to control variables in a PSD template. The panel has around 20 buttons that control visibility of certain layers/groups in the .psd file and was created using the CEP HTML Extension Cookbook. I have this part of the panel working flawlessly.
I have encountered a problem I cannot seem to get past at the moment however. I would like to create a text input field in the panel that when the user submits text, it will update the text layer within the .psd. I have not been able to figure out this step. I feel like their has to be a way to create a variable on the user's click that can then be read by the ExtendScript file to update the text in the .psd.
I believe this can be done because in the Cookbook it says the following:
----------
There is no way to access HTML extension's JavaScript DOM directly from Application's ExtendScript. If you need to access it, CEP event based communication can be used as a substitution.
CEP creates a library which uses External Object mechanism of ExtendScript to send CSXS events. The external object provides an ExtendScript class CSXSEvent for creating and dispatching application-level CSXS events. On HTML extension side, event listeners can be registered via the addEventListener
API in CSInterface.js
to listen to the events.
-----------
TLDR; I'm not a programmer by any means, but in laymans terms, is there a way to input text into an HTML panel field and then have it update a layer to that text in a .psd.
Copy link to clipboard
Copied
You need to define the CSInterface like this in your js file for your html:
var csInterface = new CSInterface();
In your jsx script, you need to create a function, that you can call from your js script:
function myFunction(myTextString){
//code here to place the variable myTextString into a text layer's content
return 'done'
}
Back in your js script you call the function in your jsx file like this:
csInterface.evalScript('myFunction(myJStextString)',whatHappened);
/*add a new function to get feedback from your jsx function - if you want it, by using the whatHappened in the above line, it will return the string "done" as in my previous example
*/
function whatHappened(w){
//w will contain "done."
}
Copy link to clipboard
Copied
hey @ChuckUebele - I tried to make this code work on my project, but I keep getting an undefined message pop up. can you peak at my code to see if it needs to be any different?