Skip to content

Commit 3810c86

Browse files
committed
控件模块的几个set方法会assert参数类型
1 parent e3fb270 commit 3810c86

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

widget.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,16 +1306,14 @@ function Widgets.inputBox:getText()
13061306
return self._value
13071307
end
13081308
function Widgets.inputBox:setText(str)
1309-
if type(str)=='string' then
1310-
self._value=str
1311-
end
1309+
if str==nil then str="" end
1310+
assert(type(str)=='string',"Arg #1 must be string")
1311+
self._value=str
13121312
end
13131313
function Widgets.inputBox:addText(str)
1314-
if type(str)=='string' then
1315-
self._value=self._value..str
1316-
else
1317-
MES.new('error',"inputBox "..self.name.." dead, addText("..type(str)..")")
1318-
end
1314+
if str==nil then str="" end
1315+
assert(type(str)=='string',"Arg #1 must be string")
1316+
self._value=self._value..str
13191317
end
13201318
function Widgets.inputBox:clear()
13211319
self._value=''
@@ -1466,9 +1464,10 @@ function Widgets.textBox:replaceTexts(newList)
14661464
self._texts=newList
14671465
self._scrollPos=0
14681466
end
1469-
function Widgets.textBox:setTexts(newList)
1467+
function Widgets.textBox:setTexts(t)
1468+
assert(type(t)=='table',"Arg #1 must be table")
14701469
TABLE.clear(self._texts)
1471-
TABLE.connect(self._texts,newList)
1470+
TABLE.connect(self._texts,t)
14721471
self._scrollPos=0
14731472
end
14741473
function Widgets.textBox:push(t)
@@ -1641,6 +1640,7 @@ function Widgets.listBox:clear()
16411640
self._scrollPos=0
16421641
end
16431642
function Widgets.listBox:setList(t)
1643+
assert(type(t)=='table',"Arg #1 must be table")
16441644
self._list=t
16451645
self._selected=1
16461646
self._scrollPos=0

0 commit comments

Comments
 (0)