Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion modules/Noble.Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ function Noble.Menu.new(__activate, __alignment, __localized, __color, __padding

self:setNumberOfRows(#self.itemNames)

-- If there is no current item (i.e. this item was added to an empty menu),
-- this item becomes the current one, so that click() works on it.
if (self.currentItemName == nil) then
self.currentItemNumber = 1
self.currentItemName = self.itemNames[1]
if (self:isActive()) then
self:setSelectedRow(1)
end
end

end

-- Internal method.
Expand Down Expand Up @@ -277,7 +287,14 @@ function Noble.Menu.new(__activate, __alignment, __localized, __color, __padding
end
end

self:setNumberOfRows(#self.itemNames)
if (#self.itemNames == 0) then
-- The menu is now empty. A gridview section must contain at least one row,
-- so we leave the row count alone and clear the current selection instead.
self.currentItemNumber = 1
self.currentItemName = nil
else
self:setNumberOfRows(#self.itemNames)
end

-- Update width
local width = 0
Expand Down Expand Up @@ -474,6 +491,7 @@ function Noble.Menu.new(__activate, __alignment, __localized, __color, __padding
-- menu:draw(50, 100)
-- end
function menu:draw(__x, __y)
if (#self.itemNames == 0) then return end
local xAdjustment = 0
if (self.alignment == Noble.Text.ALIGN_CENTER) then
xAdjustment = self.width/2
Expand Down