Skip to content

Commit a454207

Browse files
committed
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)
1 parent 18fbbe7 commit a454207

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
: Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]`
2+
Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636)
23

34
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
45
nRF5x: Remove handlers from our handlers array when a device is disconnected

libs/js/banglejs/Bangle_setUI_F18.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,12 @@
9292
if (options.redraw) // handler for redrawing the UI
9393
Bangle.uiRedraw = options.redraw;
9494
if (options.back) {
95-
var btnWatch;
9695
// only add back button handler if there's no existing watch on BTN1
9796
if (Bangle.btnWatches===undefined)
98-
btnWatch = setWatch(function() {
99-
btnWatch = undefined;
97+
Bangle.btnWatches = [ setWatch(function() {
98+
Bangle.btnWatches = undefined; // watch doesn't repeat
10099
options.back();
101-
}, BTN3, {edge:"rising"});
100+
}, BTN3, {edge:"rising"}) ];
102101
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
103102
if (global.WIDGETS && Bangle.appRect.y) {
104103
// add our own touch handler for touching in the left
@@ -116,7 +115,6 @@
116115
remove:function(noclear){
117116
var w = WIDGETS.back;
118117
if (w.area!="tl") noclear=true; // area="" is set by widget_utils.hide, so avoid drawing
119-
if (btnWatch) clearWatch(btnWatch);
120118
Bangle.removeListener("touch", touchHandler);
121119
if (!noclear) g.reset().clearRect({x:w.x, y:w.y, w:24,h:24});
122120
delete WIDGETS.back;
13 Bytes
Binary file not shown.

libs/js/banglejs/Bangle_setUI_Q3.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,11 @@
119119
Bangle.uiRedraw = options.redraw;
120120
if (options.back) {
121121
// only add back button handler if there's no existing watch on BTN1
122-
if (Bangle.btnWatches===undefined) {
122+
if (Bangle.btnWatches===undefined)
123123
Bangle.btnWatches = [ setWatch(function() {
124124
Bangle.btnWatches = undefined; // watch doesn't repeat
125125
options.back();
126126
}, BTN1, {edge:"rising"}) ];
127-
}
128127
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
129128
if (global.WIDGETS && Bangle.appRect.y) {
130129
// add our own touch handler for touching in the top left
13 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)