Skip to content

Commit 18fbbe7

Browse files
authored
Merge pull request #2636 from thyttan/setui-fix
Bangle_setUI_Q3: fix btn back handler was not always rm:ed correctly
2 parents cfabbff + ba74d7e commit 18fbbe7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

libs/js/banglejs/Bangle_setUI_Q3.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@
118118
if (options.redraw) // handler for redrawing the UI
119119
Bangle.uiRedraw = options.redraw;
120120
if (options.back) {
121-
var btnWatch;
122121
// only add back button handler if there's no existing watch on BTN1
123-
if (Bangle.btnWatches===undefined)
124-
btnWatch = setWatch(function() {
125-
btnWatch = undefined;
122+
if (Bangle.btnWatches===undefined) {
123+
Bangle.btnWatches = [ setWatch(function() {
124+
Bangle.btnWatches = undefined; // watch doesn't repeat
126125
options.back();
127-
}, BTN1, {edge:"rising"});
126+
}, BTN1, {edge:"rising"}) ];
127+
}
128128
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
129129
if (global.WIDGETS && Bangle.appRect.y) {
130130
// add our own touch handler for touching in the top left
@@ -143,7 +143,6 @@
143143
remove:function(noclear){
144144
var w = WIDGETS.back;
145145
if (w.area!="tl") noclear=true; // area="" is set by widget_utils.hide, so avoid drawing
146-
if (btnWatch) clearWatch(btnWatch);
147146
Bangle.removeListener("touch", touchHandler);
148147
if (!noclear) g.reset().clearRect({x:w.x, y:w.y, w:24,h:24});
149148
delete WIDGETS.back;

0 commit comments

Comments
 (0)