Copy link to clipboard
Copied
How can Scriptui SnpCreateDialog.jsx be changed to make "palette" that doesn't disappear upon opening? Is there a simple change or do I need to use Bridgetalk?
RONC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That's the correct beginning of the code:
function fnctn()
{
var win;
var bt;
var i;
var b1, b2, b3;
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This seems to work and is very simple to build. I removed the the "with" stuff so it is more typing but what it is doing is more apparent.
function fnctn()
{
var win;
var bt;
var i;
var b1, b2, b3;
var g0, g1, g2, g3;
win = new Window('palette');
win.spacing = 0;
win.margins = 20;
var font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.BOLD, 20);
g0 = win.add("group");
g0.orientation = "row";
g0.alignment = "center";
g0.spacing = 2;
g0.margins = 0;
g1 = g0.add("group");
g1.spacing = 0;
g1.margins = 0;
g1.preferredSize = [150, 60];
g1.graphics.backgroundColor = g1.graphics.newBrush(g1.graphics.BrushType.SOLID_COLOR, [1, 0, 0, 1]);
b1 = g1.add("statictext", undefined, "Test1");
b1.justify = "center";
b1.alignment = ["fill", "fill"];
b1.graphics.foregroundColor = b1.graphics.newPen(b1.graphics.PenType.SOLID_COLOR, [0, 1, 0, 1], 1);
b1.graphics.font = font;
b1.onClick = function () { alert(this.text); };
g3 = g0.add("group");
g3.spacing = 0;
g3.margins = 0;
g3.preferredSize = [150, 60];
g3.graphics.backgroundColor = g3.graphics.newBrush(g3.graphics.BrushType.SOLID_COLOR, [1, 1, 0, 1]);
b3 = g3.add("statictext", undefined, "Test3");
b3.justify = "center";
b3.alignment = ["fill", "fill"];
b3.graphics.foregroundColor = b3.graphics.newPen(b3.graphics.PenType.SOLID_COLOR, [0, 1, 1, 1], 1);
b3.graphics.font = font;
b3.onClick = function () { alert(this.text); };
g2 = win.add("group");
g2.spacing = 0;
g2.margins = 0;
g2.preferredSize = [150, 60];
g2.graphics.backgroundColor = g2.graphics.newBrush(g2.graphics.BrushType.SOLID_COLOR, [0, 0, 1, 1]);
b2 = g2.add("statictext", undefined, "Test2 - Close");
b2.justify = "center";
b2.alignment = ["fill", "fill"];
b2.graphics.foregroundColor = b2.graphics.newPen(b2.graphics.PenType.SOLID_COLOR, [1, 1, 0, 1], 1);
b2.graphics.font = font;
b2.onClick = function () { alert(this.text); win.close(); };
win.show();
}
(bt = new BridgeTalk()).target = 'photoshop';
bt.body = cnt(fnctn.toSource()), bt.send();
function cnt(v)
{
return 'fnctn = ' + v + '; fnctn()';
}
RONC
Copy link to clipboard
Copied
This what my CALC looks like as a PALETTE in PS2020. I applied blur and crop while it was resident and I see no problems. Had to remove all of the // comments.
I'm off to figure which type of button is best for the user error wise (clicking wrong one with plain text button vs graphically built one with symbols and colored background).
RONC
Copy link to clipboard
Copied
Copy link to clipboard
Copied
No crashes no fails!! Opened PS2020, opened image, loaded CALC, Played with CALC, blurred image, Played with CALC, cropped image, Played with CALC. Closed CALC. blurred image, loaded CALC. blurred image, played with CALC, cropped image, played with CALC. Closed PS.
Whatelse should I try?
RONC
Copy link to clipboard
Copied
Do you use a font for graphics?
Copy link to clipboard
Copied
Not sure what you are asking? If text is involved yes like in your buttons.
RONC
Copy link to clipboard
Copied
btw to use in BridgeTalk backshlashes ('\') you have firstly export lines of codes with them to binary. I mean not all, for example this simple regexp:
'123'.replace(/\d/, 0)
will be:
eval('@JSXBIN@ES@2.0@MyBbyBn0ABJAnAEXzHjSjFjQjMjBjDjFBfFeDhRhShTRCYCicjEAFdAff0DzACByB')
All other lines in the same script don't have to be converted, just only part of codes with backslashes. So maybe it's why iconbuttons (with .png source) crash Photoshop.
Copy link to clipboard
Copied
K,
Was the backslash post to me? I have no idea how to do what you are saying.
I do have a script that takes png files and makes text from it if you are interested. It does the full conversion. Send me a mail if you want it.
RONC
Copy link to clipboard
Copied
That was to r-bin who is exploring new world 🙂
Copy link to clipboard
Copied
How do I get jsxbin files of source that runs as palette to work? Nothing happens when I try to execute them. Other than that I sure thank you for the help.
RONC
Copy link to clipboard
Copied
For example it is going to alert number 1:
function fnctn(){eval('@JSXBIN@ES@2.0@MyBbyBn0ABJAnAEjzFjBjMjFjSjUBfRBFdBff0DzACByB')}
(bt = new BridgeTalk()).target = 'photoshop', bt.body = 'fnctn = ' + fnctn.toSource() + '; fnctn()', bt.send()
Copy link to clipboard
Copied
Will not run as jsxbin.
RONC
Copy link to clipboard
Copied
You may also take result of fnctn.toString() between quatition marks and put directly to bt.body as one long line. Then export the whole to jsxbin. For example:
(bt = new BridgeTalk()).target = 'photoshop';
bt.body = 'fnctn = ' + 'function fnctn(){alert(1)}' + '; fnctn()'; bt.send();
Then as I said convert it to binaries.
Copy link to clipboard
Copied
Thanks for you help. You and K have covered a lot ground for me.
RONC
Copy link to clipboard
Copied
To Kukurykus
Copy link to clipboard
Copied
I answered higher:
BridgeTalk.getSpecifier('photoshop')
When Photoshop is running you can run above command that will say, you are running one of both: photoshop-140.064 or photoshop-60.064.
You may do it also from ESTK. When Photoshop is not targeted then it will show latest installed version. When targeted (and ran) it will tell you number for targeted Photoshop.
Copy link to clipboard
Copied
super!
Copy link to clipboard
Copied
function fnctn()
{
try {
var w = Window.find("palette", "1");
if (w)
{
beep();
w.show();
return;
}
var d = new Window("palette", "1");
d.spacing = 10;
d.margins = 20;
d.b1 = d.add("button", undefined, "Test1");
d.b2 = d.add("button", undefined, "Cancel");
d.cb = d.add("checkbox", undefined, "Box");
d.b1.onClick = function () { alert(1); }
d.b2.onClick = function () { d.close(); }
d.show();
}
catch (e) { alert(e); }
}
var bt = new BridgeTalk();
var ph = BridgeTalk.getSpecifier("photoshop");
if (!ph) ph = "photoshop-60.064" // need redone
bt.target = ph;
bt.body = "var f="+fnctn.toSource()+";f();";
bt.send();
Copy link to clipboard
Copied
I used to have the same problem, but I didn't know closing doesn't clear Window objects from memory. After all BridgeTalk is another parallel process next to Photoshop. They are surely independent ones, like different applications, but working together using their features. It's why you can use Window and Ps at same time. However 'find' method solves everything 😄