Skip to main content
rechmbrs
Inspiring
March 1, 2020
質問

How can Scriptui SnpCreateDialog.jsx be changed to make "palette" that doesn't disappear?

  • March 1, 2020
  • 返信数 4.
  • 6108 ビュー

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

このトピックへの返信は締め切られました。

返信数 4

Legend
March 2, 2020
Found an interesting feature.

The window with close() command is not destroyed as a "dailog", but continues to exist and occupy memory.
Multiple calls to the script will produce many invisible windows, which can cause a crash on exit.

This code does not create duplicates but calls the old window.
 

 

 

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();

 

 

Kukurykus
Legend
March 2, 2020

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 😄

Legend
March 2, 2020

To Kukurykus

Neither works "photoshop-140" for 2020 (only "photoshop")
nor "photoshop-60" for CS6.
Or is it not that?
 
Kukurykus
Legend
March 2, 2020

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.

Legend
March 2, 2020

super!

Legend
March 1, 2020
Check this.
On Mac OS may not work on some version of Photoshop.
 

 

var font = ScriptUI.newFont("Arial", ScriptUI.FontStyle.BOLD, 20);

var d = new Window("palette");

d.spacing = 0;
d.margins = 20;

var b1;

with (d.add("panel", undefined, "", {borderStyle:"black"}))
    {
    spacing = 0;
    margins = 0;
    preferredSize = [150,60];

    graphics.backgroundColor = graphics.newBrush(graphics.BrushType.SOLID_COLOR, [1, 0, 0, 1]);

    with (b1 = add("statictext", undefined, "Test1"))
        {
        justify = "center";
        alignment = ["fill", "fill"];
        graphics.foregroundColor = graphics.newPen(graphics.PenType.SOLID_COLOR, [0, 1, 0, 1], 1);
        graphics.font = font;

        b1.onClick = function() { alert(this.text); }
        }
    }

d.show();

try {
    while (d.visible) 
        { 
        //d.active = true; 

        set_performance("stepByStep");
        } 
    }
catch (e) { set_performance("accelerated"); }    

set_performance("accelerated"); 

function set_performance(mode)
    {
    try {
        var d = new ActionDescriptor();
        var r = new ActionReference();
        r.putProperty(stringIDToTypeID("property"), stringIDToTypeID("playbackOptions"));
        r.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
        d.putReference(stringIDToTypeID("null"), r);
        var d1 = new ActionDescriptor();
        d1.putEnumerated(stringIDToTypeID("performance"), stringIDToTypeID("performance"), stringIDToTypeID(mode));
        d.putObject(stringIDToTypeID("to"), stringIDToTypeID("playbackOptions"), d1);
        executeAction(stringIDToTypeID("set"), d, DialogModes.NO);
        }
    catch (e) { throw(e); }
    }

 

 
Kukurykus
Legend
March 1, 2020

With this code you don't have access to anything in workspace.

Legend
March 1, 2020
This is a script and not an extension panel. Why do I need access?
 
Kukurykus
Legend
March 1, 2020

BridgeTalk can be used completely without Bridge (that also doesn't have to be turned on).

rechmbrs
rechmbrs作成者
Inspiring
March 1, 2020

Thanks for the quick response.

 

This code from your link opens Bridge with the palette in front of it. 

 

function bS()
{
    win = new Window('palette');
    function wa(v) { return win.add('button', [0, 0, 0, 0], v); }
    for (i = 0; i < (elements = ['About', 'Cancel']).length;)
    {
        wa(elements[i++]).onClick = function ()
        {
            if (this.text === arr[1]) win.close();
            else app.document.chooseMenuItem('mondo/command/about');
        };
    }
    win.show();
}

function cnt(v) { return 'bS=' + v + ';bS()'; }
(bt = new BridgeTalk()).target = 'bridge';
bt.body = cnt(bS.toSource()), bt.send(2);

   Do I need photoshop as target? 

 

RONC

rechmbrs
rechmbrs作成者
Inspiring
March 1, 2020

With target set to photoshop it runs in photoshop but only closes when photoshop is closed.  Neither of the buttons do anything.

 

RONC