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