feat(menumodel): add a widget limit
This commit is contained in:
parent
a3e2da3972
commit
12b4b3fbc1
1 changed files with 8 additions and 0 deletions
|
@ -16,6 +16,7 @@ function MenuModel:new()
|
|||
self.selected = 0
|
||||
self.selectedPrevious = 0
|
||||
self.cancel = 0
|
||||
self.limit = -1
|
||||
-- self:updateWidgetSize()
|
||||
end
|
||||
|
||||
|
@ -24,6 +25,10 @@ function MenuModel:clear()
|
|||
self.cancel = 0
|
||||
end
|
||||
|
||||
function MenuModel:setLimit(limit)
|
||||
self.limit = limit
|
||||
end
|
||||
|
||||
-- UPDATE/DRAW FUNCTIONS
|
||||
-- All the update functions
|
||||
|
||||
|
@ -70,6 +75,9 @@ end
|
|||
-- All the functions to handle widgets
|
||||
|
||||
function MenuModel:addWidget(newWidget)
|
||||
if (self.limit ~= -1 and #self.list >= self.limit) then
|
||||
return
|
||||
end
|
||||
if #self.list == 0 then
|
||||
self.selected = 1
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue