mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[feat] Add Device:hasClipboard() (#3465)
References https://github.com/koreader/koreader/issues/3441
This commit is contained in:
@@ -383,8 +383,11 @@ function ReaderHighlight:onHoldRelease()
|
||||
},
|
||||
{
|
||||
{
|
||||
text = "-",
|
||||
enabled = false,
|
||||
text = "Copy",
|
||||
enabled = Device:hasClipboard(),
|
||||
callback = function()
|
||||
Device.input.setClipboardText(self.selected_text.text)
|
||||
end,
|
||||
},
|
||||
{
|
||||
text = _("Translate"),
|
||||
|
||||
@@ -24,6 +24,7 @@ local Device = {
|
||||
isTouchDevice = no,
|
||||
hasFrontlight = no,
|
||||
needsTouchScreenProbe = no,
|
||||
hasClipboard = no,
|
||||
hasColorScreen = no,
|
||||
|
||||
-- use these only as a last resort. We should abstract the functionality
|
||||
|
||||
@@ -34,10 +34,22 @@ function Device:init()
|
||||
end
|
||||
|
||||
if util.haveSDL2() then
|
||||
self.hasClipboard = yes
|
||||
self.screen = require("ffi/framebuffer_SDL2_0"):new{device = self, debug = logger.dbg}
|
||||
|
||||
local input = require("ffi/input")
|
||||
self.input = require("device/input"):new{
|
||||
device = self,
|
||||
event_map = require("device/sdl/event_map_sdl2"),
|
||||
hasClipboardText = function()
|
||||
return input.hasClipboardText()
|
||||
end,
|
||||
getClipboardText = function()
|
||||
return input.getClipboardText()
|
||||
end,
|
||||
setClipboardText = function(text)
|
||||
return input.setClipboardText(text)
|
||||
end,
|
||||
}
|
||||
else
|
||||
self.screen = require("ffi/framebuffer_SDL1_2"):new{device = self, debug = logger.dbg}
|
||||
|
||||
Reference in New Issue
Block a user