mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Menu widget: draw focus on focused item (#12583)
This commit is contained in:
@@ -299,6 +299,8 @@ FocusManager.NOT_UNFOCUS = 1
|
||||
FocusManager.NOT_FOCUS = 2
|
||||
-- In some cases, we may only want to send Focus events on non-Touch devices
|
||||
FocusManager.FOCUS_ONLY_ON_NT = (Device:hasDPad() and not Device:isTouchDevice()) and 0 or FocusManager.NOT_FOCUS
|
||||
-- And in some cases, we may want to send both events *regardless* of heuristics or device caps
|
||||
FocusManager.FORCED_FOCUS = 4
|
||||
|
||||
--- Move focus to specified widget
|
||||
function FocusManager:moveFocusTo(x, y, focus_flags)
|
||||
@@ -319,7 +321,11 @@ function FocusManager:moveFocusTo(x, y, focus_flags)
|
||||
self.selected.x = x
|
||||
self.selected.y = y
|
||||
-- widget create new layout on update, previous may be removed from new layout.
|
||||
if Device:hasDPad() then
|
||||
if bit.band(focus_flags, FocusManager.FORCED_FOCUS) == FocusManager.FORCED_FOCUS or Device:hasDPad() then
|
||||
-- If FORCED_FOCUS was requested, we want *all* the events: mask out both NOT_ bits
|
||||
if bit.band(focus_flags, FocusManager.FORCED_FOCUS) == FocusManager.FORCED_FOCUS then
|
||||
focus_flags = bit.band(focus_flags, bit.bnot(bit.bor(FocusManager.NOT_UNFOCUS, FocusManager.NOT_FOCUS)))
|
||||
end
|
||||
if bit.band(focus_flags, FocusManager.NOT_UNFOCUS) ~= FocusManager.NOT_UNFOCUS then
|
||||
-- NOTE: We can't necessarily guarantee the integrity of self.layout,
|
||||
-- as some callers *will* mangle it and call us expecting to fix things ;).
|
||||
|
||||
Reference in New Issue
Block a user