Created
December 6, 2022 09:08
-
-
Save monokano/62a23e8d0a0b5ac8d672a4d451841636 to your computer and use it in GitHub Desktop.
Illustratorの「コピー元のレーヤーにペースト」をモーダルウィンドウ上でON/OFFするJavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Illustratorの「コピー元のレーヤーにペースト」をモーダルウィンドウ上でON/OFFする | |
var b = app.preferences.getBooleanPreference('layers/pastePreserve'); | |
var status = ""; | |
var buttonText = "" | |
if ( b ){ | |
status = "ON"; | |
buttonText = "OFF"; | |
}else{ | |
status = "OFF"; | |
buttonText = "ON"; | |
} | |
var result = multiBtnDlg("コピー元のレイヤーにペースト", "現状:"+status, [buttonText, "Close"], 1); | |
if(result===0){ | |
app.preferences.setBooleanPreference('layers/pastePreserve',!b); | |
} | |
// モーダルウインドウ | |
// https://uske-s.hatenablog.com/entry/2018/08/08/191022 | |
function multiBtnDlg(title, text, list, focus) { | |
var cDlg = new Window("dialog", title); | |
cDlg.add("statictext", undefined, text, {multiline: true}); | |
var btnGrp = cDlg.add("group"); | |
var btnList = []; | |
for (var i=0; i<list.length; i++) { | |
if (i === focus) { | |
btnList.push(btnGrp.add("button", undefined, list[i], {name: "ok"})); | |
} else { | |
btnList.push(btnGrp.add("button", undefined, list[i])); | |
} | |
eval( | |
"btnList[i].onClick = function() {\n"+ | |
" cDlg.close("+(i)+");\n"+ | |
"}"); | |
} | |
return cDlg.show(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment