gpt4 book ai didi

javascript - 使用 Photoshop 脚本创建一个带有 3 个按钮的面板

转载 作者:行者123 更新时间:2023-12-03 02:51:57 25 4
gpt4 key购买 nike

我想创建一个带有 3 个按钮的面板:

  1. 按钮 - 添加图像 1
  2. 按钮 - 添加图像 2
  3. 取消
<小时/>
var dlg = new Window( "dialog", "Alert Box Builder" );
dlg.btnPnl = dlg.add( "panel", undefined, "Build it" );
dlg.btnPnl.testBtn = dlg.btnPnl.add( "button", undefined, "Test" );
dlg.btnPnl.buildBtn = dlg.btnPnl.add( "button", undefined, "Build", {name: "ok" } );
dlg.btnPnl.cancelBtn = dlg.btnPnl.add( "button", undefined, "Cancel", { name: "cancel" } );
dlg.show();

最佳答案

你走在正确的道路上!执行此操作只需要再添加一个按钮,然后为这些按钮添加一个特殊的 onClick 函数。该函数将打开操作系统的文件浏览器,然后将文件分配给 pic1Filepic2File 变量。

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

希望有帮助!

关于javascript - 使用 Photoshop 脚本创建一个带有 3 个按钮的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47813097/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com