Merge pull request #76 from dpavlin/issue_55_multikey

Issue #55 multikey support
This commit is contained in:
{Qingping,Dave} Hou
2012-03-27 20:17:00 -07:00
3 changed files with 14 additions and 6 deletions

View File

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

View File

@@ -123,6 +123,8 @@ end
function setEmuKeycodes()
KEY_PGFWD = 117
KEY_PGBCK = 112
KEY_LPGBCK = 69 -- F3
KEY_LPGFWD = 70 -- F4
KEY_HOME = 110 -- home
KEY_BACK = 22 -- backspace
KEY_DEL = 119 -- Delete

View File

@@ -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())
@@ -1175,6 +1175,5 @@ function UniReader:addAllCommands()
end
end)
-- end panning
--print defined commands
--for k,v in pairs(self.commands.map) do print(v) end
print("## defined commands "..dump(self.commands.map))
end