From db17b225d0751131675484d9ea56a0eac9adf616 Mon Sep 17 00:00:00 2001 From: BartS23 <10829389+BartS23@users.noreply.github.com> Date: Mon, 9 Jan 2023 14:33:52 +0100 Subject: [PATCH] add setItem to clock_info --- modules/clock_info.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/clock_info.js b/modules/clock_info.js index 4d4aba622..b826e5760 100644 --- a/modules/clock_info.js +++ b/modules/clock_info.js @@ -296,6 +296,20 @@ exports.addInteractive = function(menu, options) { options.redraw = function() { drawItem(menu[options.menuA].items[options.menuB]); }; + options.setItem = function (menuA, menuB) { + if (!menu[menuA] || !menu[menuA].items[menuB] || (options.menuA == menuA && options.menuB == menuB)) { + // menuA or menuB did not exist or did not change + return false; + } + + const oldMenuItem = menu[options.menuA].items[options.menuB]; + if (oldMenuItem) { + menuHideItem(oldMenuItem); + oldMenuItem.removeAllListeners("draw"); + menuShowItem(menu[menuA].items[menuB]); + } + return true; + } return options; };