Last active
September 2, 2023 06:53
-
-
Save monokano/94099a2db46751456ca96b0f6e8b4e12 to your computer and use it in GitHub Desktop.
InDesignの「スマートガイド」を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
// 「スマートガイド」をON/OFFする v3 | |
var b = app.smartGuidePreferences.enabled; | |
var status = ""; | |
var buttonText = "" | |
if ( b ){ | |
status = "ON"; | |
buttonText = "OFF"; | |
}else{ | |
status = "OFF"; | |
buttonText = "ON"; | |
} | |
var result = multiBtnDlg("スマートガイド", "現状:"+status, ["Close", buttonText], 1); | |
if(result===1){ | |
app.smartGuidePreferences.enabled = !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
v3でボタンを逆にしました。
v2
・変更する ボタンをマウスクリック
・変更せずに閉じる returnキー
V3
・変更する returnキー
・変更せずに閉じる cmd+ピリオド
どちらもキー操作できるように改善しました。