如何解决未选中复选框时如何禁用输入框
这是对话框中复选框和输入框的脚本。我想知道如何在未选中复选框的情况下禁用该条目。
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”启用/禁用该功能来启用/禁用该条目。
最初,该条目被“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,3)
TagGroup entry2 = DLGCreateRealField("Parameter 2 : ",para2,6,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()
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。