Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)

This commit is contained in:
Gordon Williams 2025-06-10 10:24:15 +01:00
parent 18fbbe7fa3
commit a454207e03
5 changed files with 5 additions and 7 deletions

View File

@ -1,4 +1,5 @@
: Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
nRF5x: Remove handlers from our handlers array when a device is disconnected

View File

@ -92,13 +92,12 @@
if (options.redraw) // handler for redrawing the UI
Bangle.uiRedraw = options.redraw;
if (options.back) {
var btnWatch;
// only add back button handler if there's no existing watch on BTN1
if (Bangle.btnWatches===undefined)
btnWatch = setWatch(function() {
btnWatch = undefined;
Bangle.btnWatches = [ setWatch(function() {
Bangle.btnWatches = undefined; // watch doesn't repeat
options.back();
}, BTN3, {edge:"rising"});
}, BTN3, {edge:"rising"}) ];
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
if (global.WIDGETS && Bangle.appRect.y) {
// add our own touch handler for touching in the left
@ -116,7 +115,6 @@
remove:function(noclear){
var w = WIDGETS.back;
if (w.area!="tl") noclear=true; // area="" is set by widget_utils.hide, so avoid drawing
if (btnWatch) clearWatch(btnWatch);
Bangle.removeListener("touch", touchHandler);
if (!noclear) g.reset().clearRect({x:w.x, y:w.y, w:24,h:24});
delete WIDGETS.back;

Binary file not shown.

View File

@ -119,12 +119,11 @@
Bangle.uiRedraw = options.redraw;
if (options.back) {
// only add back button handler if there's no existing watch on BTN1
if (Bangle.btnWatches===undefined) {
if (Bangle.btnWatches===undefined)
Bangle.btnWatches = [ setWatch(function() {
Bangle.btnWatches = undefined; // watch doesn't repeat
options.back();
}, BTN1, {edge:"rising"}) ];
}
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
if (global.WIDGETS && Bangle.appRect.y) {
// add our own touch handler for touching in the top left

Binary file not shown.