目前正在使用 JavaScript 为 Indesign CS6 开发脚本。我正在寻找一种在对话框 UI 中为标签添加颜色的方法。示例代码如下:
var myDialog = app.dialogs.add({name:"User Interface Example Script", canCancel:true});
with(myDialog){
//Add a dialog column.
with(dialogColumns.add()){
//Create a border panel.
with(borderPanels.add()){
with(dialogColumns.add()){
//The following line shows how to set a property as you create an object.
staticTexts.add({staticLabel:"Message:"});
我想知道如何使该标签 Message 成为自定义颜色。
我找到了使用 JavaScript API 中的其他类的部分解决方案,但是我仍然想知道上述是否可行。
var w = new Window("dialog");
var s = w.add ("statictext", undefined, "Static");
var e = w.add ("edittext", undefined, "Edit");
var b = w.add ("button", undefined, "Button");
// The window's backround
w.graphics.backgroundColor = w.graphics.newBrush (w.graphics.BrushType.SOLID_COLOR, [0.5, 0.0, 0.0]);
// Font and its colour for the first item, statictext
s.graphics.font = ScriptUI.newFont ("Helvetica", "Bold", 30);
s.graphics.foregroundColor = s.graphics.newPen (w.graphics.PenType.SOLID_COLOR, [0.7, 0.7, 0.7], 1);
// Font and colours for the second item, edittext
e.graphics.font = ScriptUI.newFont ("Letter Gothic Std", "Bold", 30);
e.graphics.foregroundColor = e.graphics.newPen (e.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);
e.graphics.backgroundColor = e.graphics.newBrush (e.graphics.BrushType.SOLID_COLOR, [0.5, 0.5, 0.5]);
// Font for the tird control, a button. Can't set colours in buttons
b.graphics.font = ScriptUI.newFont ("Minion Pro", "Italic", 30);
w.show ();