mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[DictQuickLookup] NT: add text selection to the dictionary widget (#13232)
Initially, when you open the dictionary widget from the reader, FocusManager will function as usual. On Kindle 4 or devices with a keyboard, I have assigned the shortcuts <kbd>screenkb</kbd> + <kbd>up</kbd>/<kbd>down</kbd> or <kbd>shift</kbd> + <kbd>up</kbd>/<kbd>down</kbd> to initiate text selection (as a remainder, on kindle text selection in reader is initiated with <kbd>up</kbd>/<kbd>down</kbd> so it is fairly similar). At this point, FocusManager is disabled, allowing the cursor keys (and press) to control the now-visible crosshairs. Pressing <kbd>back</kbd> should stop text selection and restore FocusManager’s control of the widget.
This commit is contained in:
@@ -3,6 +3,7 @@ local BlitBuffer = require("ffi/blitbuffer")
|
||||
local ButtonDialog = require("ui/widget/buttondialog")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local DoubleSpinWidget = require("ui/widget/doublespinwidget")
|
||||
local Event = require("ui/event")
|
||||
local Geom = require("ui/geometry")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
@@ -798,25 +799,39 @@ Except when in two columns mode, where this is limited to showing only the previ
|
||||
if not Device:isTouchDevice() and Device:hasDPad() then
|
||||
table.insert(menu_items.long_press.sub_item_table, {
|
||||
text_func = function()
|
||||
return T(_("Crosshairs speed for text selection: %1"), G_reader_settings:readSetting("highlight_non_touch_factor") or 4)
|
||||
local reader_speed = G_reader_settings:readSetting("highlight_non_touch_factor") or 4
|
||||
local dict_speed = G_reader_settings:readSetting("highlight_non_touch_factor_dict") or 3
|
||||
return T(_("Crosshairs speed (reader/dict): %1 / %2"), reader_speed, dict_speed)
|
||||
end,
|
||||
callback = function(touchmenu_instance)
|
||||
local curr_val = G_reader_settings:readSetting("highlight_non_touch_factor") or 4
|
||||
local spin_widget = SpinWidget:new{
|
||||
value = curr_val,
|
||||
value_min = 0.25,
|
||||
value_max = 5,
|
||||
precision = "%.2f",
|
||||
value_step = 0.25,
|
||||
default_value = 4,
|
||||
local reader_speed = G_reader_settings:readSetting("highlight_non_touch_factor") or 4
|
||||
local dict_speed = G_reader_settings:readSetting("highlight_non_touch_factor_dict") or 3
|
||||
local double_spin_widget = DoubleSpinWidget:new{
|
||||
left_text = _("Reader"),
|
||||
left_value = reader_speed,
|
||||
left_min = 0.25,
|
||||
left_max = 5,
|
||||
left_default = 4,
|
||||
left_precision = "%.2f",
|
||||
left_step = 0.25,
|
||||
left_hold_step = 0.05,
|
||||
right_text = _("Dictionary"),
|
||||
right_value = dict_speed,
|
||||
right_min = 0.25,
|
||||
right_max = 5,
|
||||
right_default = 3,
|
||||
right_precision = "%.2f",
|
||||
right_step = 0.25,
|
||||
right_hold_step = 0.05,
|
||||
title_text = _("Crosshairs speed"),
|
||||
info_text = _("Select a decimal value from 0.25 to 5. A smaller value increases the travel distance of the crosshairs per keystroke. Font size and this value are inversely correlated, meaning a smaller font size requires a larger value and vice versa."),
|
||||
callback = function(spin)
|
||||
G_reader_settings:saveSetting("highlight_non_touch_factor", spin.value)
|
||||
callback = function(left_value, right_value)
|
||||
G_reader_settings:saveSetting("highlight_non_touch_factor", left_value)
|
||||
G_reader_settings:saveSetting("highlight_non_touch_factor_dict", right_value)
|
||||
if touchmenu_instance then touchmenu_instance:updateItems() end
|
||||
end
|
||||
}
|
||||
UIManager:show(spin_widget)
|
||||
UIManager:show(double_spin_widget)
|
||||
end,
|
||||
})
|
||||
table.insert(menu_items.long_press.sub_item_table, {
|
||||
|
||||
Reference in New Issue
Block a user