【发布时间】:2020-04-14 13:32:46
【问题描述】:
当用户点击 dm 脚本中的按钮时,如何将元素添加到可见对话框?
我的目标是一个输入对话框,允许用户选择他想要处理的图像。这可以是多个图像。因此,我想设计一个提供 add 按钮的对话框。单击该按钮会添加一个选择框 (DLGCreateImagePopup()) 用于选择图像。
我的问题是我没有找到更新对话框 UI 的方法。它不会重绘内容。唯一接近我的问题的是这篇关于how to enable and disable an element 的帖子。该帖子建议使用UIFrame.close(),后跟UIFrame.display(),但即将出现的对话框不再是模态的。将UIFrame.display() 更改为UIFrame.pose(),对话框就会消失。当尝试再次执行脚本时,错误 Class already declared: 'TestDialog' 出现。那我得重启GMS了。
以下脚本会创建如图所示的对话框。单击“添加”时,“按下按钮”行。应该会出现,但什么也没发生。
TagGroup dialog_items;
TagGroup dialog_tags = DLGCreateDialog("Test dialog", dialog_items);
TagGroup group = DLGCreateGroup();
group.DLGIdentifier("group");
dialog_items.DLGAddElement(group);
TagGroup label = DLGCreateLabel("Press the 'Add' button.");
group.DLGAddElement(label);
TagGroup add = DLGCreatePushButton("Add", "addButtonPressed");
group.DLGAddElement(add);
class TestDialog : UIFrame{
void addButtonPressed(object self){
TagGroup g = self.LookUpElement("group");
TagGroup l = DLGCreateLabel("Button pressed.");
g.DLGAddElement(l);
self.ValidateView(); // <- does nothing
// self.close();
// self.display(""); // <- doesn't show as modal
// self.close();
// self.pose(); // <- doesn't show up, forces to restart GMS
}
}
Object dialog = alloc(TestDialog).init(dialog_tags);
dialog.Pose();
【问题讨论】:
标签: user-interface dialog updates dm-script