Currently developing a script for Indesign CS6, using JavaScript. I am looking for a way to add color to the labels in a dialog UI. The sample code is as follows:
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:"});
I wonder how you can make that label Message a custom color.
I've found a partial solution using other classes from the JavaScript API however I would still like to know if the above is possible.
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 ();
If you look at the API, there are two separate classes for static text (StaticText (SUI)
and StaticText
). It looks like the first class StaticText (SUI) offers the ability to color static text whereas the second StaticText does not.
In your question, the first code snippet you show is using the StaticText
class, so graphic options (colors) aren't available to it. The second code sample is using the StaticText (SUI)
class, that's why you're able to color it.
I found a nice overview, that you might be interested in, of the difference between the UI APIs here.
So, to answer your question, in order to add color to the dialog you would have to create your own dialog using a window and the Scripting UI classes (SUI) instead of using the "built in" dialog class.