如何在未选中复选框时禁用输入框
How to disable the entry box while the checkbox is not selected
这是对话框中复选框和输入框的脚本。我想知道如何在未选中复选框时禁用该条目。
class TestUI : UIFrame {
number true, false
TestUI(object self) {
true = 1;
false = 0;
result("[TestUI] constructed\n")
};
~TestUI(object self) {
result("[TestUI] destructed\n")
};
void CreateDialog(object self) {
TagGroup dialog = DLGCreateDialog("Test")
TagGroup cb = DLGCreateCheckbox("IsCheck",false).DLGAnchor("West")
TagGroup parameter
TagGroup entry = DLGCreateRealField("Parameter : ",parameter,5,8,1)
dialog.DLGAddElement(cb)
dialog.DLGAddElement(entry)
self.init(dialog).Display("TestUI")
};
};
{
alloc(TestUI).CreateDialog()
}
提前致谢。
查看手册后,我找到了解决方案。
通过添加函数并在更改复选框时使用“SetElementIsEnabled”enable/disable 函数,条目可以 enabled/disable。
最初,条目被“DLGEnabled”禁用。
这是脚本:
class TestUI : UIFrame {
number true, false
TagGroup para1, para2
TestUI(object self) {
true = 1;
false = 0;
result("[TestUI] constructed\n")
};
~TestUI(object self) {
result("[TestUI] destructed\n")
};
void SelectionAct(object self, TagGroup tgItem) {
// To change the status while the checkbox is changing.
self.SetElementIsEnabled("BtnGroup",tgItem.DLGGetValue())
};
void BtnResponse(object self) {
result("Parameter 1 : "+para1.DLGGetValue()+"\n")
result("Parameter 2 : "+para2.DLGGetValue()+"\n")
};
void CreateDialog(object self) {
// the box is not selected when initiation
// To enable/disable the entry by building "SelectionAct" function
TagGroup cb = DLGCreateCheckbox("IsCheck",false,"SelectionAct").DLGAnchor("West")
TagGroup entry1 = DLGCreateRealField("Parameter 1 : ",para1,5,5,3)
TagGroup entry2 = DLGCreateRealField("Parameter 2 : ",para2,6,5,3)
// print the value
TagGroup Btn = DLGCreatePushButton("Print","BtnResponse").DLGFill("X").DLGIdentifier("btn")
// Group the entries and button, we can change their status with ease.
TagGroup EntryGroup = DLGGroupItems(entry1,entry2).DLGTableLayout(2,1,0).DLGIdentifier("entries")
TagGroup BtnGroup = DLGGroupItems(EntryGroup,Btn).DLGTableLayout(1,2,0).DLGIdentifier("BtnGroup")
// disable the entries and btn when initiation
DLGEnabled(BtnGroup,false)
// create dialog
TagGroup dialog = DLGCreateDialog("Test")
dialog.DLGAddElement(cb)
dialog.DLGAddElement(BtnGroup)
self.init(dialog).Display("TestUI")
};
};
{
alloc(TestUI).CreateDialog()
}
结果:
这是对话框中复选框和输入框的脚本。我想知道如何在未选中复选框时禁用该条目。
class TestUI : UIFrame {
number true, false
TestUI(object self) {
true = 1;
false = 0;
result("[TestUI] constructed\n")
};
~TestUI(object self) {
result("[TestUI] destructed\n")
};
void CreateDialog(object self) {
TagGroup dialog = DLGCreateDialog("Test")
TagGroup cb = DLGCreateCheckbox("IsCheck",false).DLGAnchor("West")
TagGroup parameter
TagGroup entry = DLGCreateRealField("Parameter : ",parameter,5,8,1)
dialog.DLGAddElement(cb)
dialog.DLGAddElement(entry)
self.init(dialog).Display("TestUI")
};
};
{
alloc(TestUI).CreateDialog()
}
提前致谢。
查看手册后,我找到了解决方案。 通过添加函数并在更改复选框时使用“SetElementIsEnabled”enable/disable 函数,条目可以 enabled/disable。
最初,条目被“DLGEnabled”禁用。
这是脚本:
class TestUI : UIFrame {
number true, false
TagGroup para1, para2
TestUI(object self) {
true = 1;
false = 0;
result("[TestUI] constructed\n")
};
~TestUI(object self) {
result("[TestUI] destructed\n")
};
void SelectionAct(object self, TagGroup tgItem) {
// To change the status while the checkbox is changing.
self.SetElementIsEnabled("BtnGroup",tgItem.DLGGetValue())
};
void BtnResponse(object self) {
result("Parameter 1 : "+para1.DLGGetValue()+"\n")
result("Parameter 2 : "+para2.DLGGetValue()+"\n")
};
void CreateDialog(object self) {
// the box is not selected when initiation
// To enable/disable the entry by building "SelectionAct" function
TagGroup cb = DLGCreateCheckbox("IsCheck",false,"SelectionAct").DLGAnchor("West")
TagGroup entry1 = DLGCreateRealField("Parameter 1 : ",para1,5,5,3)
TagGroup entry2 = DLGCreateRealField("Parameter 2 : ",para2,6,5,3)
// print the value
TagGroup Btn = DLGCreatePushButton("Print","BtnResponse").DLGFill("X").DLGIdentifier("btn")
// Group the entries and button, we can change their status with ease.
TagGroup EntryGroup = DLGGroupItems(entry1,entry2).DLGTableLayout(2,1,0).DLGIdentifier("entries")
TagGroup BtnGroup = DLGGroupItems(EntryGroup,Btn).DLGTableLayout(1,2,0).DLGIdentifier("BtnGroup")
// disable the entries and btn when initiation
DLGEnabled(BtnGroup,false)
// create dialog
TagGroup dialog = DLGCreateDialog("Test")
dialog.DLGAddElement(cb)
dialog.DLGAddElement(BtnGroup)
self.init(dialog).Display("TestUI")
};
};
{
alloc(TestUI).CreateDialog()
}
结果: