2
0
mirror of https://github.com/koreader/koreader synced 2024-11-16 06:12:56 +00:00

[fix] Use orderedPairs in touch menu item table (#6404)

Cf. <https://github.com/koreader/koreader/pull/6403> and <https://github.com/koreader/koreader/pull/6371>.
This commit is contained in:
Frans de Jonge 2020-07-20 20:58:39 +02:00 committed by GitHub
parent 45d2dff86c
commit 8e66494ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -8,6 +8,7 @@ local BottomContainer = require("ui/widget/container/bottomcontainer")
local Button = require("ui/widget/button")
local CenterContainer = require("ui/widget/container/centercontainer")
local Device = require("device")
local FFIUtil = require("ffi/util")
local FocusManager = require("ui/widget/focusmanager")
local Font = require("ui/font")
local FrameContainer = require("ui/widget/container/framecontainer")
@ -1326,7 +1327,7 @@ end
function Menu.itemTableFromTouchMenu(t)
local item_t = {}
for k,v in pairs(t) do
for k, v in FFIUtil.orderedPairs(t) do
local item = { text = k }
if v.callback then
item.callback = v.callback

View File

@ -20,7 +20,11 @@ describe("Menu widget", function()
},
})
--- @fixme: Currently broken because pairs (c.f., https://github.com/koreader/koreader/pull/6371#issuecomment-657251302)
assert.are.same(re, {
assert.are.same({
{
text = 'exit',
callback = cb2,
},
{
text = 'navi',
sub_item_table = {
@ -29,10 +33,6 @@ describe("Menu widget", function()
{ text = 'bar', callback = cb2 },
}
},
{
text = 'exit',
callback = cb2,
}
})
}, re)
end)
end)