From 00556715f4270fdc7fa2e1ca8cdcd80dec137e2d Mon Sep 17 00:00:00 2001 From: yparitcher Date: Thu, 7 Jan 2021 17:19:23 -0500 Subject: [PATCH] Dispatcher: update document.configurable (#7116) So ConfigDialog knows about changed settings and properly reflects their states. --- frontend/dispatcher.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/dispatcher.lua b/frontend/dispatcher.lua index 884f5145f..27b37b1fb 100644 --- a/frontend/dispatcher.lua +++ b/frontend/dispatcher.lua @@ -23,6 +23,7 @@ Each setting contains: * args: allowed values for string. * toggle: display name for args * separator: put a separator after in the menu list +* configurable: can be parsed from cre/kopt and used to set document.configurable. Should not be set manualy --]]-- local CreOptions = require("ui/data/creoptions") @@ -289,6 +290,9 @@ function Dispatcher:init() for y=1,#base[i].options do local option = base[i].options[y] if settingsList[option.name] ~= nil then + if option.name ~= nil and option.values ~= nil then + settingsList[option.name].configurable = {name = option.name, values = option.values} + end if settingsList[option.name].event == nil then settingsList[option.name].event = option.event end @@ -619,6 +623,15 @@ function Dispatcher:execute(ui, settings, gesture) local arg = v ~= 0 and v or gesture or 0 ui:handleEvent(Event:new(settingsList[k].event, arg)) end + if settingsList[k].configurable ~= nil then + local value = v + if type(v) ~= "number" then + for i, r in ipairs(settingsList[k].args) do + if v == r then value = settingsList[k].configurable.values[i] break end + end + end + ui.document.configurable[settingsList[k].configurable.name] = value + end end end end