2013-01-09 43 views
2

目前正在爲使用javascript的indesign CS6開發腳本。我正在尋找一種方式來在對話框中的用戶界面增添色彩標籤,示例代碼如下所示Indesign腳本:如何在對話框中添加顏色staticTexts

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:"}); 

我不知道你是如何作出這樣的標籤信息自定義顏色。

**編輯

我發現使用從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(); 
+0

我不認爲這是可能的只是與JavaScript。您可能想了解一下Adobe爲製作UI所提供的其他解決方案。 –

+0

@JoshVoigts對不起,這是不正確的,這是可能的,它非常靈活,我會用一些代碼來編輯我的問題,這些代碼部分地完成了我正在尋找的內容。 – Guevara

+0

啊,我站好了,我猜你每天都會學到新的東西 –

回答

1

如果你看一下API的部分解決方案,對於靜態文本有兩個單獨的類(StaticText (SUI)StaticText)。它看起來像第一類StaticText (SUI)提供了彩色靜態文本的能力,而第二個StaticText沒有。

在你的問題中,你顯示的第一個代碼片段是使用StaticText類,所以圖形選項(顏色)不可用。第二個代碼示例使用的是StaticText (SUI)類,這就是爲什麼您可以爲它着色的原因。

我發現了一個很好的概述,您可能會對UI API here之間的區別感興趣。

因此,要回答你的問題,爲了給對話框添加顏色,你必須使用窗口和腳本UI類(SUI)而不是使用「內置」對話框類創建自己的對話框。

+0

是的,我得出了同樣的結論,感謝您的輸入 – Guevara

相關問題