mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Dispatcher:removeAction()
Gestures: use sub_item_table_func to allow the menu to refresh on change
This commit is contained in:
@@ -36,6 +36,7 @@ local Notification = require("ui/widget/notification")
|
||||
local ReaderZooming = require("apps/reader/modules/readerzooming")
|
||||
local Screen = require("device").screen
|
||||
local UIManager = require("ui/uimanager")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = require("ffi/util").template
|
||||
@@ -440,6 +441,20 @@ function Dispatcher:registerAction(name, value)
|
||||
return true
|
||||
end
|
||||
|
||||
--[[--
|
||||
Removes settings at runtime.
|
||||
|
||||
@param name the key to use in the table
|
||||
--]]--
|
||||
function Dispatcher:removeAction(name)
|
||||
local k = util.arrayContains(dispatcher_menu_order, name)
|
||||
if k then
|
||||
table.remove(dispatcher_menu_order, k)
|
||||
settingsList[name] = nil
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- Returns a display name for the item.
|
||||
function Dispatcher:getNameFromItem(item, location, settings)
|
||||
if settingsList[item] == nil then
|
||||
@@ -631,7 +646,7 @@ arguments are:
|
||||
3) the object (table) in which the settings table is found
|
||||
4) the name of the settings table
|
||||
example usage:
|
||||
Dispatcher.addSubMenu(self, sub_items, self.data, "profile1")
|
||||
Dispatcher:addSubMenu(self, sub_items, self.data, "profile1")
|
||||
--]]--
|
||||
function Dispatcher:addSubMenu(caller, menu, location, settings)
|
||||
Dispatcher:init()
|
||||
|
||||
@@ -240,7 +240,7 @@ function Gestures:genSubItem(ges, separator, hold_callback)
|
||||
return {
|
||||
text_func = function() return self:gestureTitleFunc(ges) end,
|
||||
enabled_func = enabled_func,
|
||||
sub_item_table = self:genMenu(ges),
|
||||
sub_item_table_func = function() return self:genMenu(ges) end,
|
||||
separator = separator,
|
||||
hold_callback = hold_callback,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user