button1.onChanging

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

lee ky
Posts: 22
Joined: Tue Mar 03, 2020 3:59 am

button1.onChanging

Post by lee ky »

var doc = activeDocument;
var fontname=doc.activeLayer.textItem.font

var w = new Window ("dialog");

var button1 = w.add ("Button", [0,0,180,20], "1");
button1.active = true
button1.text ="Font_Name"
button1.preferredSize.width = 180;
button1.onChanging = function(){ button1.text = fontname};

w.show()

I'd like to change it to a font name when I click the button.
It doesn't work well.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: button1.onChanging

Post by Kukurykus »

lee ky
Posts: 22
Joined: Tue Mar 03, 2020 3:59 am

Re: button1.onChanging

Post by lee ky »

Thank you very much.
I referred to the sauce below.

--------------------------------------------------------------------

#target photoshop
var pic1File;
var pic2File;

var dlg = new Window( "dialog", "Alert Box Builder" );
btnPnl = dlg.add( "panel", undefined, "Build it" );
pic1Btn = btnPnl.add( "button", undefined, "Image 1" );
pic2Btn = btnPnl.add( "button", undefined, "Image 2" );
buildBtn = btnPnl.add( "button", undefined, "Build", {name: "ok" } );
cancelBtn = btnPnl.add( "button", undefined, "Cancel", { name: "cancel" } );

pic1Btn.onClick = function() {
pic1File = new File;
pic1File = pic1File.openDlg ( "Select Background Image", "Images: *.png; *.jpeg; *.jpg" )
if( pic1File != null ) { pic1Btn.text = File.decode ( pic1File.name ) }
else {
pic1File = new File;
pic1Btn.text = "No file selected";
}
}

pic2Btn.onClick = function() {
pic2File = new File;
pic2File = pic2File.openDlg ( "Select Background Image", "Images: *.png; *.jpeg; *.jpg" )
if( pic2File != null ) { pic2Btn.text = File.decode ( pic2File.name ) }
else {
pic2File = new File;
pic2Btn.text = "No file selected";
}
}

dlg.show();
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: button1.onChanging

Post by Kukurykus »

Where's the correlation to original 'font' issue?