TouchMenu: added hook to show help text on long-press (#3980)

When Hold and there is no hold callback attached to a menu item, a help_text
attribute, when present, is shown in an InfoMessage.
pull/3989/head
poire-z 6 years ago committed by GitHub
parent fe03a3c3fd
commit 9b6b91b743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -95,6 +95,7 @@ function ReaderLink:addToMainMenu(menu_items)
not isTapToFollowLinksOn())
end,
separator = true,
help_text = _([[Tap on links to follow them.]]),
},
{
@ -104,6 +105,7 @@ function ReaderLink:addToMainMenu(menu_items)
G_reader_settings:saveSetting("swipe_to_go_back",
not isSwipeToGoBackEnabled())
end,
help_text = _([[Swipe to the right to go back to the previous location after you have followed a link. When the location stack is empty, swiping to the right takes you to the previous page.]]),
},
{
text = _("Swipe to follow first link on page"),
@ -115,6 +117,7 @@ function ReaderLink:addToMainMenu(menu_items)
G_reader_settings:delSetting("swipe_to_follow_nearest_link") -- can't have both
end
end,
help_text = _([[Swipe to the left to follow the first link in the current page.]]),
},
{
text = _("Swipe to follow nearest link"),
@ -126,6 +129,7 @@ function ReaderLink:addToMainMenu(menu_items)
G_reader_settings:delSetting("swipe_to_follow_first_link") -- can't have both
end
end,
help_text = _([[Swipe to the left to follow the link nearest to where you started the swipe. This is useful when a small font is used and tapping on small links is tedious.]]),
separator = true,
},
{
@ -135,6 +139,9 @@ function ReaderLink:addToMainMenu(menu_items)
G_reader_settings:saveSetting("swipe_to_jump_to_latest_bookmark",
not isSwipeToJumpToLatestBookmarkEnabled())
end,
help_text = _([[Swipe to the left to go the most recently bookmarked page.
This can be useful to quickly swipe back and forth between what you are reading and some reference page (for example notes, a map or a characters list).
If any of the other Swipe to follow link options is enabled, this will work only when the current page contains no link.]]),
},
}
}

@ -15,6 +15,7 @@ local GestureRange = require("ui/gesturerange")
local HorizontalGroup = require("ui/widget/horizontalgroup")
local HorizontalSpan = require("ui/widget/horizontalspan")
local IconButton = require("ui/widget/iconbutton")
local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer")
local LeftContainer = require("ui/widget/container/leftcontainer")
local LineWidget = require("ui/widget/linewidget")
@ -719,7 +720,7 @@ function TouchMenu:onMenuHold(item)
else
self:onInput(item.hold_input_func())
end
else
elseif item.hold_callback or type(item.hold_callback_func) == "function" then
local callback = item.hold_callback
if item.hold_callback_func then
callback = item.hold_callback_func()
@ -734,6 +735,14 @@ function TouchMenu:onMenuHold(item)
end
end)
end
elseif item.help_text or type(item.help_text_func) == "function" then
local help_text = item.help_text
if item.help_text_func then
help_text = item.help_text_func()
end
if help_text then
UIManager:show(InfoMessage:new{ text = help_text, })
end
end
return true
end

Loading…
Cancel
Save