specify multiple keys for single command #55

This code still doesn't support different modifiers on keys, but
I would rather refactor it in small steps first

Current changes adds support for Kindle 3 left page keys
reported by @houqp in issue #55
pull/2/merge
Dobrica Pavlinusic 12 years ago
parent d3318beb84
commit 69a8ee83bb

@ -62,8 +62,15 @@ Commands = {
size = 0
}
function Commands:add(keycode,modifier,keydescr,help,func)
local keydef = Keydef:new(keycode,modifier,keydescr)
self:_addImpl(keydef,help,func)
if type(keycode) == "table" then
for i=1,#keycode,1 do
local keydef = Keydef:new(keycode[i],modifier,keydescr)
self:_addImpl(keydef,help,func)
end
else
local keydef = Keydef:new(keycode,modifier,keydescr)
self:_addImpl(keydef,help,func)
end
end
function Commands:addGroup(keygroup,keys,help,func)
for _k,keydef in pairs(keys) do

@ -875,12 +875,12 @@ end
-- command definitions
function UniReader:addAllCommands()
self.commands = Commands:new()
self.commands:add(KEY_PGFWD,nil,">",
self.commands:add({KEY_PGFWD,KEY_LPGFWD},nil,">",
"next page",
function(unireader)
unireader:goto(unireader:nextView())
end)
self.commands:add(KEY_PGBCK,nil,"<",
self.commands:add({KEY_PGBCK,KEY_LPGBCK},nil,"<",
"previous page",
function(unireader)
unireader:goto(unireader:prevView())

Loading…
Cancel
Save