feat(menumodel): add a widget limit

This commit is contained in:
Kazhnuz 2020-11-29 12:50:07 +01:00
parent a3e2da3972
commit 12b4b3fbc1

View file

@ -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