IUP for Lua 如何将数组存储的vbox/hbox控件显示至主窗口?
IUP for Lua 动态渲染GUI控件显示异常问题
问题背景
使用IUP for Lua开发时,编写了用于完成特定操作后向主窗口动态渲染GUI元素的函数,遇到控件显示异常,不同实现方式的表现如下:
测试场景表现
- 正常测试场景
不使用数组存储vbox/hbox容器,直接向现有hrbox追加元素时,测试用输入框可正常显示;将元素渲染到新窗口的测试也可正常运行。
对应实现代码:function wa() local txt = {} txt[1] = iup.text{ multiline = "NO", padding = "5x5", size="100x15", scrollbar="Horizontal", } iup.Append(hrbox, txt[1]) iup.Map(txt[1]) iup.Refresh(hrbox) end - 异常场景1
在函数内声明数组变量存储hbox/vbox容器时,元素完全不显示,主窗口、新窗口都无法正常渲染对应元素。
对应测试代码:function wa() local txt = {} local a = {} a[1] = iup.vbox{} txt[1] = iup.text{ multiline = "NO", padding = "5x5", size="100x15", scrollbar="Horizontal", } iup.Append(a[1], txt[1]) iup.Map(txt[1]) iup.Refresh(a[1]) iup.Append(hrbox, a[1]) iup.Refresh(hrbox) end - 异常场景2
将用于承载主窗口元素的hrbox容器改为在函数内单独声明创建时,元素无法在主窗口正常渲染,仅能在新窗口中显示。
对应测试代码:function wa() local txt = {} hrbox = iup.hbox{} a = {} a[1] = iup.vbox{} txt[1] = iup.text{ multiline = "NO", padding = "5x5", size="100x15", scrollbar="Horizontal", } iup.Append(a[1], txt[1]) iup.Map(txt[1]) iup.Refresh(a[1]) iup.Append(hrbox, a[1]) iup.Refresh(hrbox) end
用户诉求
查阅相关资料后未解决该问题,需要可行的实现方案与建议,让数组存储的vbox/hbox类型控件能够成功显示到主窗口中。
内容的提问来源于stack exchange,提问作者ITmaster
相关产品推荐
相关产品推荐

