• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to call a file on the performance of CC 2014 via the click of a button

Participant ,
Oct 25, 2015 Oct 25, 2015

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.

TOPICS
Actions and scripting

Views

528

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Oct 27, 2015 Oct 27, 2015

Nothing immediatelly pops into my eye..

  • Are you sure you need the extensionRoot.substr, sample doesn't have it?
  • File is in right place? I don't use Brackets and the plugin for that, but it needs to copy all necessary files in the right place.
  • When you change things, you need to close the panel in Photoshop so it will reload the files.
  • Does the jsx run at all (you can add alerts in there also)?

Votes

Translate

Translate
Adobe
Enthusiast ,
Oct 25, 2015 Oct 25, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 26, 2015 Oct 26, 2015

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

HTML Panels Tips #2 Including multiple JSX  Photoshop, etc. — Opera.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 27, 2015 Oct 27, 2015

Copy link to clipboard

Copied

Nothing immediatelly pops into my eye..

  • Are you sure you need the extensionRoot.substr, sample doesn't have it?
  • File is in right place? I don't use Brackets and the plugin for that, but it needs to copy all necessary files in the right place.
  • When you change things, you need to close the panel in Photoshop so it will reload the files.
  • Does the jsx run at all (you can add alerts in there also)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 27, 2015 Oct 27, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 27, 2015 Oct 27, 2015

Copy link to clipboard

Copied

it is possible to create window in HTML and write scripts in JS ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 27, 2015 Oct 27, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 28, 2015 Oct 28, 2015

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 :-)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 29, 2015 Oct 29, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 29, 2015 Oct 29, 2015

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 ?

• jsmain.js (com.example.lab2cc) - Brackets.jpg

PrtScr capture_2.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 30, 2015 Oct 30, 2015

Copy link to clipboard

Copied

LATEST

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)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines