如何修复在Corona SDK中调用窗口小部件方法时产生的零值错误?

时间:2016-03-28 23:53:41

标签: lua corona

如何修复在Corona SDK中调用窗口小部件方法时产生的零值错误?

 local widget = require('widget')

-- Text Box
 local myTextField = widget.newTextField(
{     
     top = 10,
     left = 20,
     width = 200,
     height = 30,
     cornerRadius = 8,
     strokeWidth = 3,
     backgroundColor = {1,1,1},
     strokeColor = {0,0,0},
     font = 'Helvetica',
     fontsize = 24,
     listener = textFieldHandler    
}
)

1 个答案:

答案 0 :(得分:0)

根据文档小部件,仅提供以下功能:

https://docs.coronalabs.com/api/library/widget/

widget.newButton()
widget.newPickerWheel()
widget.newProgressView()
widget.newScrollView()
widget.newSegmentedControl()
widget.newSlider()
widget.newSpinner()
widget.newStepper()
widget.newSwitch()
widget.newTabBar()
widget.newTableView()
widget.setTheme()

你可以避免错误消息,我假设它就像错误:尝试calla nil值,只需不调用nil值widget.newTextField

另一个选择是自己实现它,如下所述:

https://coronalabs.com/blog/2013/12/03/tutorial-customizing-text-input/

由于本教程与您的代码完全匹配,我认为您只是懒得阅读超出第一段......

enter image description here