mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
fix: move shiftmode and altmode to global
now shiftmode and altmode is recoreded in Keys module. So all the UIs are sharing these two mode instead of remembering their own. These fix the bug in UI switchings. For instance, you use combo 'Alt'+'b' to fire up some menu in pdfreader, the altmode is set, but the alt key was released after the menu show up. Then the key release event will only be captured by the menu. So after you exit from the menu, the altmode is still set in pdfreader, which is not what we want.
This commit is contained in:
@@ -356,27 +356,27 @@ function PDFReader:inputloop()
|
||||
if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
|
||||
local secs, usecs = util.gettime()
|
||||
if ev.code == KEY_SHIFT then
|
||||
self.shiftmode = true
|
||||
Keys.shiftmode = true
|
||||
elseif ev.code == KEY_ALT then
|
||||
self.altmode = true
|
||||
Keys.altmode = true
|
||||
elseif ev.code == KEY_PGFWD or ev.code == KEY_LPGFWD then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self:setglobalzoom(self.globalzoom*1.2)
|
||||
elseif self.altmode then
|
||||
elseif Keys.altmode then
|
||||
self:setglobalzoom(self.globalzoom*1.1)
|
||||
else
|
||||
self:goto(self.pageno + 1)
|
||||
end
|
||||
elseif ev.code == KEY_PGBCK or ev.code == KEY_LPGBCK then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self:setglobalzoom(self.globalzoom*0.8)
|
||||
elseif self.altmode then
|
||||
elseif Keys.altmode then
|
||||
self:setglobalzoom(self.globalzoom*0.9)
|
||||
else
|
||||
self:goto(self.pageno - 1)
|
||||
end
|
||||
elseif ev.code == KEY_BACK then
|
||||
if self.altmode then
|
||||
if Keys.altmode then
|
||||
-- altmode, exit pdfreader
|
||||
self:clearcache()
|
||||
if self.doc ~= nil then
|
||||
@@ -399,19 +399,19 @@ function PDFReader:inputloop()
|
||||
elseif ev.code == KEY_VMINUS then
|
||||
self:modify_gamma( 0.8 )
|
||||
elseif ev.code == KEY_A then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT)
|
||||
else
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE)
|
||||
end
|
||||
elseif ev.code == KEY_S then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
else
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_WIDTH)
|
||||
end
|
||||
elseif ev.code == KEY_D then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_CONTENT_HEIGHT)
|
||||
else
|
||||
self:setglobalzoommode(self.ZOOM_FIT_TO_PAGE_HEIGHT)
|
||||
@@ -430,10 +430,10 @@ function PDFReader:inputloop()
|
||||
local x
|
||||
local y
|
||||
|
||||
if self.shiftmode then -- shift always moves in small steps
|
||||
if Keys.shiftmode then -- shift always moves in small steps
|
||||
x = self.shift_x / 2
|
||||
y = self.shift_y / 2
|
||||
elseif self.altmode then
|
||||
elseif Keys.altmode then
|
||||
x = self.shift_x / 5
|
||||
y = self.shift_y / 5
|
||||
elseif self.pan_by_page then
|
||||
@@ -469,7 +469,7 @@ function PDFReader:inputloop()
|
||||
self.offset_y = self.min_offset_y
|
||||
end
|
||||
elseif ev.code == KEY_FW_PRESS then
|
||||
if self.shiftmode then
|
||||
if Keys.shiftmode then
|
||||
self.offset_x = 0
|
||||
self.offset_y = 0
|
||||
else
|
||||
@@ -487,9 +487,9 @@ function PDFReader:inputloop()
|
||||
print("E: T="..ev.type.." V="..ev.value.." C="..ev.code.." DUR="..dur)
|
||||
elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_SHIFT then
|
||||
print "shift haha"
|
||||
self.shiftmode = false
|
||||
Keys.shiftmode = false
|
||||
elseif ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_RELEASE and ev.code == KEY_ALT then
|
||||
self.altmode = false
|
||||
Keys.altmode = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user