2015-01-26 35 views
1

爲什麼下面的腳本沒有禁用按鈕,因爲它應該這樣做?如何啓用 - 禁用對話框對象中的元素 - DLGEnabled

class ElementEnableTest : UIFrame { 

    void Action(object self) { 
     self.LookUpElement("StopButton").DLGEnabled(0); 
     result("button clicked\n"); 
    }; 

    ElementEnableTest(object self) { 
     TagGroup tgDialog = DLGCreateDialog(""); 
     TagGroup tgButton = DLGCreatePushButton("stop","Action"); 
     tgButton.DLGIdentifier("StopButton"); 
     tgDialog.DLGAddElement(tgButton); 
     self.init(tgDialog); 
     self.Display("test"); 
    }; 
}; 

alloc(ElementEnableTest); 

回答

1

腳本動作

self.LookUpElement("StopButton").DLGEnabled(0); 

將設置在相關tagStructure屬性值(其描述對話框),但它不會強制對話框繪圖的更新。 (請注意,DLGTitleDLGSetProgress等其他UI命令確實會強制更新。)

顯示期間禁用/啓用UI元素的命令爲SetElementIsEnabled。因此,請使用以下行代替您的:

self.SetElementIsEnabled("StopButton",0); 

這會按照您的要求做。


第二種蠻力的方式是讓對話框窗口關閉並重新創建,但我認爲您通常會想要避免這種情況。

void Action(object self) { 
    self.LookUpElement("StopButton").DLGEnabled(0); 
    self.close() 
    self.display("") 
    result("button clicked\n"); 
};