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する v2 | |
var b = app.smartGuidePreferences.enabled; | |
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.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
InDesignのメニューを見なくても「スマートガイド」の現状確認ができ、ON/OFFの変更もできます。