Skip to content

Commit 6f6d4d7

Browse files
author
thyttan
committed
messagegui: move hw btn action to back fn of E.showScroller
Instead of adding an external button handler. This works now that [the red back widget is not added if widgets are not shown](espruino/Espruino@453def8). This means we should wait for fw 2v26 stable before maybe merging this change to espruino/BangleApps.
1 parent f01b30d commit 6f6d4d7

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

apps/messagegui/app.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ function showMessagesScroller(msg) {
377377
break;
378378
}
379379
}
380+
},
381+
back: function () {
382+
if (!persist) { return load(); }
383+
Bangle.removeListener("touch", touchHandler);
384+
Bangle.emit("touch", 1, { x: Math.floor(APP_RECT.x2 / 2), y: Math.floor(APP_RECT.y2 / 2), type: { back: true } });
380385
}
381386
});
382387

@@ -389,32 +394,14 @@ function showMessagesScroller(msg) {
389394
returnToMain();
390395
E.stopEventPropagation();
391396
Bangle.removeListener("touch", touchHandler);
392-
if (btnWatch) {clearWatch(btnWatch); btnWatch = undefined;}
393397
} else if (xy && xy.type===0 && xy.x>175-30 && xy.y<30) {
394398
Bangle.emit("touch", 2, {x:Math.floor(APP_RECT.x2/2), y:Math.floor(APP_RECT.y2/2), type:0});
395399
E.stopEventPropagation();
396-
if (btnWatch) {clearWatch(btnWatch); btnWatch = undefined;}
397400
Bangle.removeListener("touch", touchHandler);
398401
}
399402
};
400403
Bangle.prependListener("touch", touchHandler);
401404

402-
// If Bangle.js 2 add an external back hw button handler.
403-
let btnWatch;
404-
if (2===process.env.HWVERSION) {
405-
btnWatch = setWatch(()=>{
406-
if ("scroller"!==active) {return;}
407-
Bangle.emit("drag", {dy:0}); // Compatibility with `kineticscroll`, stopping the scroller so it doesn't continue scrolling when the `showMessageOverview` screen is loaded.
408-
// Zero ms timeout as to not move on before the scroller has registered the emitted drag event.
409-
setTimeout(()=>{
410-
if (!persist) {return load();}
411-
Bangle.removeListener("touch", touchHandler);
412-
Bangle.emit("touch",1, {x:Math.floor(APP_RECT.x2/2), y:Math.floor(APP_RECT.y2/2), type:{back:true}});
413-
},0);
414-
}, BTN);
415-
}
416-
417-
418405
function updateReadMessages() {
419406
let shownMsgIdxFirst, shownMsgIdxLast;
420407
const LINES_PER_SCREEN = APP_RECT.h/FONT_HEIGHT;

0 commit comments

Comments
 (0)