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

View Palette

Engaged ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

Hello everyone, everything good?
I'm trying to create a script that has two types of dialog boxes, a main and a second window, which when opened I can manipulate the elements of the main window. The solution would be a palette-type window, but I have no idea how to make it stay open when executed.
Is there any chance this pallete will be visible when executed? Thanks.

dlg = new Window("palette"); 
dlg.text = "Dialog"; 
dlg.orientation = "column"; 
dlg.alignChildren = ["center","top"]; 

array=[];
p1 = dlg.add("panel", undefined, undefined, {name: "p1"}); 
p1.text = "Panel"; 
p1.preferredSize.width = 150; 
p1.orientation = "column"; 
p1.alignChildren = ["left","top"]; 
p1.spacing = 10; 
p1.margins = 10; 

var valor = 25.00;
b1 = dlg.add("button", undefined, undefined, {name: "b1"}); 
b1.text = "Adicionar"; 
b1.preferredSize.width = 150; 

adiconar();
b2 = dlg.add("button", undefined, undefined, {name: "b2"}); 
b2.text = "Somar"; 
b2.preferredSize.width = 150; 

dlg.layout.layout (true);
b1.onClick = function(){
adiconar();
}

function adiconar(){
    t1 = p1.add("Button"); t1.text = "✔ Moldura 1 : R$ " + valor;
    array.push([ t1.text.split("R$")[1] ]);
    dlg.layout.layout (true);
}

b2.onClick = function(){
	var soma_total = 0;
	for (i = 0; i < array.length; i++) {
		soma_total += Number(array[i]);
		}
    b2.text ="R$: "+ soma_total.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
}

dlg.show();
TOPICS
Actions and scripting

Views

430

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

Guide , Aug 03, 2022 Aug 03, 2022

Votes

Translate

Translate
Adobe
Guide ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

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
Engaged ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

@jazz-y  Thanks! You are a genius! The palette worked fine, however I tried to run the palette by clicking a button in the main dialog and I noticed that the palette only opens when the main window is closed, the idea would be to keep both of them open. You as a great genius that you are, would you know of any method that I can fix this?

var dialog = new Window("dialog"); 
dialog.text = "Dialog"; 
dialog.orientation = "column"; 
dialog.alignChildren = ["center","top"]; 
dialog.spacing = 10; 
dialog.margins = 16; 

var button1 = dialog.add("button", undefined, undefined, {name: "button1"}); 
button1.text = "Button"; 

button1.onClick = function(){adicionar_mais()}

dialog.show();




function adicionar_mais(){

	var bt = new BridgeTalk(); 
	bt.target = "photoshop"; 
	bt.body = "var palette = " + fn.toString() + "; palette();"
	bt.send(); 

	function fn () {
		dlg = new Window("palette",  undefined, undefined, {closeButton:true}); 
		dlg.text = "Dialog"; 
		dlg.orientation = "column"; 
		dlg.alignChildren = ["center","top"]; 

		array=[];
		p1 = dlg.add("panel", undefined, undefined, {name: "p1"}); 
		p1.text = "Panel"; 
		p1.preferredSize.width = 150; 
		p1.orientation = "column"; 
		p1.alignChildren = ["left","top"]; 
		p1.spacing = 10; 
		p1.margins = 10; 

		var valor = 25.00;
		b1 = dlg.add("button", undefined, undefined, {name: "b1"}); 
		b1.text = "Adicionar"; 
		b1.preferredSize.width = 150; 

		adiconar();
		b2 = dlg.add("button", undefined, undefined, {name: "b2"}); 
		b2.text = "Somar"; 
		b2.preferredSize.width = 150; 

		dlg.layout.layout (true);
		b1.onClick = function(){
		adiconar();
		}

		function adiconar(){
			t1 = p1.add("Button"); t1.text = "✔ Moldura 1 : R$ " + valor;
			array.push([ t1.text.split("R$")[1] ]);
			dlg.layout.layout (true);
		}

		b2.onClick = function(){
			var soma_total = 0;
			for (i = 0; i < array.length; i++) {
				soma_total += Number(array[i]);
				}
			b2.text ="R$: "+ soma_total.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
		}

		dlg.show();
	}


}

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
Guide ,
Aug 11, 2022 Aug 11, 2022

Copy link to clipboard

Copied

Using a window in palette mode has certain limitations. You can try to start both windows in this mode, but it seems to me that it is easier to change interface logic so that there is no need to interact with two windows at the same time.

var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body = "var palette = " + fn.toString() + "; palette();"
bt.send();
function fn() {
    var dialog = new Window("palette", undefined, undefined, { closeButton: true });
    dialog.text = "Dialog";
    dialog.orientation = "column";
    dialog.alignChildren = ["center", "top"];
    dialog.spacing = 10;
    dialog.margins = 16;
    var button1 = dialog.add("button", undefined, undefined, { name: "button1" });
    button1.text = "Button";
    button1.onClick = function () { adicionar_mais() };
    dialog.show();
    function adicionar_mais() {
        var bt = new BridgeTalk();
        bt.target = "photoshop";
        bt.body = "var palette = " + fn.toString() + "; palette();"
        bt.send();
        function fn() {
            dlg = new Window("dialog", undefined, undefined, { closeButton: true });
            dlg.text = "Dialog";
            dlg.orientation = "column";
            dlg.alignChildren = ["center", "top"];
            array = [];
            p1 = dlg.add("panel", undefined, undefined, { name: "p1" });
            p1.text = "Panel";
            p1.preferredSize.width = 150;
            p1.orientation = "column";
            p1.alignChildren = ["left", "top"];
            p1.spacing = 10;
            p1.margins = 10;
            var valor = 25.00;
            b1 = dlg.add("button", undefined, undefined, { name: "b1" });
            b1.text = "Adicionar";
            b1.preferredSize.width = 150;
            adiconar();
            b2 = dlg.add("button", undefined, undefined, { name: "b2" });
            b2.text = "Somar";
            b2.preferredSize.width = 150;
            dlg.layout.layout(true);
            b1.onClick = function () {
                adiconar();
            }
            function adiconar() {
                t1 = p1.add("Button"); t1.text = "✔ Moldura 1 : R$ " + valor;
                array.push([t1.text.split("R$")[1]]);
                dlg.layout.layout(true);
            }
            b2.onClick = function () {
                var soma_total = 0;
                for (i = 0; i < array.length; i++) {
                    soma_total += Number(array[i]);
                }
                b2.text = "R$: " + soma_total.toFixed(2).replace('.', ',').replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
            }
            dlg.show();
        }
    }
}

 

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
Engaged ,
Aug 12, 2022 Aug 12, 2022

Copy link to clipboard

Copied

@jazz-y thanks for kindly fulfilling my request.

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
Explorer ,
Jan 29, 2023 Jan 29, 2023

Copy link to clipboard

Copied

How to this type create in  " PaletteButton"Screenshot 2023-01-29 192820.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
Community Expert ,
Feb 05, 2023 Feb 05, 2023

Copy link to clipboard

Copied

LATEST

Hi, it seems that you post in multiple scripting threads, and are trying to develop a full commercial automation product, why not take the time to learn it with resources such as https://www.ps-scripting.com/uxp-react.html

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