mirror of https://github.com/espruino/BangleApps
Move input handling inside setUI (Bangle2)
parent
b468ac3498
commit
cd5367977f
|
@ -3,6 +3,8 @@
|
|||
*
|
||||
* Original Author: Frederic Rousseau https://github.com/fredericrous
|
||||
* Created: April 2020
|
||||
*
|
||||
* Contributors: thyttan https://github.com/thyttan
|
||||
*/
|
||||
|
||||
g.clear();
|
||||
|
@ -402,29 +404,27 @@ if (process.env.HWVERSION==1) {
|
|||
swipeEnabled = false;
|
||||
drawGlobal();
|
||||
} else { // touchscreen?
|
||||
Bangle.setUI({ // Pressing upper left corner turns off (where red back button would be)
|
||||
mode : 'custom',
|
||||
back : load
|
||||
});
|
||||
setWatch(_ => {load();}, BTN1, {edge:'falling'}); // Exit with a short press to physical button
|
||||
selected = "NONE";
|
||||
swipeEnabled = true;
|
||||
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
|
||||
prepareScreen(operators, operatorsGrid, COLORS.OPERATOR);
|
||||
prepareScreen(specials, specialsGrid, COLORS.SPECIAL);
|
||||
drawNumbers();
|
||||
Bangle.on('touch',(n,e)=>{
|
||||
|
||||
Bangle.setUI({
|
||||
mode : 'custom',
|
||||
back : load, // Clicking physical button or pressing upper left corner turns off (where red back button would be)
|
||||
touch : (n,e)=>{
|
||||
for (var key in screen) {
|
||||
if (typeof screen[key] == "undefined") break;
|
||||
var r = screen[key].xy;
|
||||
if (e.x>=r[0] && e.y>=r[1] &&
|
||||
e.x<r[2] && e.y<r[3]) {
|
||||
if (e.x>=r[0] && e.y>=r[1] && e.x<r[2] && e.y<r[3]) {
|
||||
//print("Press "+key);
|
||||
buttonPress(""+key);
|
||||
}
|
||||
}
|
||||
});
|
||||
Bangle.on('swipe', (LR, UD) => {
|
||||
},
|
||||
swipe : (LR, UD) => {
|
||||
if (LR == 1) { // right
|
||||
drawSpecials();
|
||||
}
|
||||
|
@ -437,7 +437,9 @@ if (process.env.HWVERSION==1) {
|
|||
if (UD == -1) { // up
|
||||
drawNumbers();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
displayOutput(0);
|
||||
|
|
Loading…
Reference in New Issue