Ah, great about Bangle.removeListener()!
Generating the layout anew when exiting onHelp() makes the buttons pressable. I suspect there's a better way to do it though. Test here. Code here .
What I changed (line 1, 7, 12 and 41 below):
function onHelp(resolve,reject) { Bangle.removeListener("swipe", onSwipe); E.showPrompt( helpMessage, {title: "Help", buttons : {"Ok":true}} ).then(function(v) { Bangle.on('swipe', onSwipe); generateLayout(resolve,reject); layout.render(); }); } function generateLayout(resolve,reject) { layout = new Layout( { type:"v", c: [ {type:"txt", font:"10%", label:text, id:"text", cb: l=>onHelp(resolve,reject), fillx:1}, {type:"h", c: [ {type:"btn", font:fontSize, label:letters[1], cb: l=>onKeyPad(1), id:'1', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[2], cb: l=>onKeyPad(2), id:'2', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[3], cb: l=>onKeyPad(3), id:'3', fillx:1, filly:1 }, ]}, {type:"h", filly:1, c: [ {type:"btn", font:fontSize, label:letters[4], cb: l=>onKeyPad(4), id:'4', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[5], cb: l=>onKeyPad(5), id:'5', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[6], cb: l=>onKeyPad(6), id:'6', fillx:1, filly:1 }, ]}, {type:"h", filly:1, c: [ {type:"btn", font:fontSize, label:letters[7], cb: l=>onKeyPad(7), id:'7', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[8], cb: l=>onKeyPad(8), id:'8', fillx:1, filly:1 }, {type:"btn", font:fontSize, label:letters[9], cb: l=>onKeyPad(9), id:'9', fillx:1, filly:1 }, ]}, ] },{back: ()=>{ Bangle.setUI(); Bangle.removeListener("swipe", onSwipe); g.clearRect(Bangle.appRect); resolve(text); }}); } return new Promise((resolve,reject) => { generateLayout(resolve,reject); g.clearRect(Bangle.appRect); Bangle.on('swipe', onSwipe); layout.render(); });
. . The help message is a good idea! Maybe it can be displayed directly on first launch as well? Something like this at the beginning of the promise:
var settings = require('Storage').readJSON("kbmulti.settings.json", true) || {}; if (!settings.firstLaunch) { onHelp(resolve,reject); settings.firstLaunch = false; require('Storage').writeJSON("kbmulti.settings.json", settings); }
@Ganblejs started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ah, great about Bangle.removeListener()!
Generating the layout anew when exiting onHelp() makes the buttons pressable. I suspect there's a better way to do it though.
Test here.
Code here .
What I changed (line 1, 7, 12 and 41 below):
.
.
The help message is a good idea! Maybe it can be displayed directly on first launch as well?
Something like this at the beginning of the promise: