2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/frontend/ui/elements/menu_keyboard_layout.lua
yparitcher 5e8d1227ef [feat, UX] Pick keyboard layout from keyboard (#5583)
* Tap goes to next activated keyboard.
* Hold opens a selection popup.
2019-11-18 17:16:06 +01:00

33 lines
1.2 KiB
Lua

local Language = require("ui/language")
local VirtualKeyboard = require("ui/widget/virtualkeyboard")
local orderedPairs = require("ffi/util").orderedPairs
local sub_item_table = {}
for k, _ in orderedPairs(VirtualKeyboard.lang_to_keyboard_layout) do
table.insert(sub_item_table, {
text_func = function()
local text = Language:getLanguageName(k)
if VirtualKeyboard:getKeyboardLayout() == k then
text = text .. ""
end
return text
end,
checked_func = function()
local keyboard_layouts = G_reader_settings:readSetting("keyboard_layouts") or {}
return keyboard_layouts[k] == true
end,
callback = function()
local keyboard_layouts = G_reader_settings:readSetting("keyboard_layouts") or {}
keyboard_layouts[k] = not keyboard_layouts[k]
G_reader_settings:saveSetting("keyboard_layouts", keyboard_layouts)
end,
hold_callback = function(touchmenu_instance)
G_reader_settings:saveSetting("keyboard_layout", k)
if touchmenu_instance then touchmenu_instance:updateItems() end
end,
})
end
return sub_item_table