From 1ba083b706adabc4f3233cb82fbf1f8fa18add36 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Mon, 1 Jul 2024 22:50:21 +0200 Subject: [PATCH] Bangle_setUI_Q3: set custom handlers on any mode TODO: Not thoroughly tested yet. First discussed here around here: https://github.com/espruino/BangleApps/issues/3435#issuecomment-2160293792 --- libs/js/banglejs/Bangle_setUI_Q3.js | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libs/js/banglejs/Bangle_setUI_Q3.js b/libs/js/banglejs/Bangle_setUI_Q3.js index 3a30c43a96..07bdac3fb5 100644 --- a/libs/js/banglejs/Bangle_setUI_Q3.js +++ b/libs/js/banglejs/Bangle_setUI_Q3.js @@ -85,28 +85,28 @@ setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) ]; } else if (mode=="custom") { - if (options.clock) Bangle.CLOCK=1; - if (options.touch) - Bangle.touchHandler = options.touch; - if (options.drag) { - Bangle.dragHandler = options.drag; - Bangle.on("drag", Bangle.dragHandler); - } - if (options.swipe) { - Bangle.swipeHandler = options.swipe; - Bangle.on("swipe", Bangle.swipeHandler); - } - if (options.btn) { - Bangle.btnWatches = [ - setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}) - ]; - } else if (options.clock) { - Bangle.btnWatches = [ - setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) - ]; - } } else throw new Error("Unknown UI mode "+E.toJS(mode)); + if (options.clock) Bangle.CLOCK=1; + if (options.touch) + Bangle.touchHandler = options.touch; + if (options.drag) { + Bangle.dragHandler = options.drag; + Bangle.on("drag", Bangle.dragHandler); + } + if (options.swipe) { + Bangle.swipeHandler = options.swipe; + Bangle.on("swipe", Bangle.swipeHandler); + } + if (options.btn) { + Bangle.btnWatches = [ + setWatch(function() { options.btn(1); }, BTN1, {repeat:1,edge:"falling"}) + ]; + } else if (options.clock) { + Bangle.btnWatches = [ + setWatch(Bangle.showLauncher, BTN1, {repeat:1,edge:"falling"}) + ]; + } if (options.remove) // handler for removing the UI (intervals/etc) Bangle.uiRemove = options.remove; if (options.redraw) // handler for redrawing the UI