User Patch – Open Dictionary Directly After Very Long Press, Pop Up Dialog Still Accessible within Pencil Icon
Description
This patch enables a "More" button inside the dictionary input dialog, which opens the full highlight pop-up dialog with actions.
It also includes a bypass mechanism: long final hold (very long press) triggers a direct dictionary lookup without opening the highlight pop-up dialog first.
How to Use:
- You don't need to activate open dictionary on single word selection
- A very long press (long final hold) opens the dictionary directly, bypassing the default highlight dialog.
- You can accessed the Pop Up Dialog by clicking the Pencil Icon, then in the input dialog, click on More
- Pop Up Dialog (Default Very Long Press Action) will appear and Functional
Additional Notes
- You can still access it normally via "ask with popup dialog" (long press without triggering the dictionary).
Outside the patched flow, KOReader remains fully intact.
To get the best experience:
Set your "very long press" interval only slightly longer than your "long press" in KOReader settings (e.g., 0.5s vs 0.7s).
This allows a comfortable flow between select and highlight text and opening the dictionary with minimal effort.
Disclaimer
I am not a programmer and doesn't understand programming language. This patch was created through experimentation and assistance from ChatGPT, with testing on KOReader for Android and Kindle. If you have improvements, feel free to fork, modify, or suggest changes—contributions are welcome.
2-final-patch-popup-dictionary.lua.txt
local ReaderHighlight = require("apps/reader/modules/readerhighlight")
local DictQuickLookup = require("ui/widget/dictquicklookup")
local UIManager = require("ui/uimanager")
local util = require("util")
local _ = require("gettext")
-- PATCH 1: Tangkap seleksi dari long final hold tanpa dummy
local orig_onHoldRelease = ReaderHighlight.onHoldRelease
ReaderHighlight.onHoldRelease = function(self)
local long_final_hold = self.long_hold_reached
self:_resetHoldTimer(true)
if long_final_hold and self.selected_text then
-- Simpan seleksi untuk dipakai nanti di Patch 2
ReaderHighlight.onHoldSelectedText = util.tableDeepCopy(self.selected_text)
-- Tampilkan kamus seperti biasa
self:lookupDict()
self:onClose()
return true
end
return orig_onHoldRelease(self)
end
-- PATCH 2: Tambah tombol More ke input dialog dan gunakan seleksi yang valid
local orig_lookup = DictQuickLookup.onLookupInputWord
DictQuickLookup.onLookupInputWord = function(self, hint)
orig_lookup(self, hint)
local hl = self.ui and self.ui.highlight
if not hl or not self.input_dialog then return end
-- Tambahkan tombol "More"
table.insert(self.input_dialog._buttons_backup, {
{
text = _("More"),
callback = function()
-- Gunakan seleksi dari long final hold jika tersedia
if not hl.selected_text and ReaderHighlight.onHoldSelectedText then
hl.selected_text = util.tableDeepCopy(ReaderHighlight.onHoldSelectedText)
hl.hold_pos = hl.hold_pos or (hl.selected_text.sboxes and hl.selected_text.sboxes[1])
ReaderHighlight.onHoldSelectedText = nil
end
UIManager:close(self.input_dialog)
self:onClose()
hl:onShowHighlightMenu()
end
}
})
self.input_dialog:reinit()
end
Very Long Press on Text
Dictionary Opened after Very Long Press on Text
Input Dialog After Clicking The Pencil Icon
Pop Up Dialog