mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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
This commit is contained in:
11
commands.lua
11
commands.lua
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user