Change order, add more comments for setUI

pull/2827/head
stweedo 2023-06-16 12:57:58 -05:00
parent 6fe81e3279
commit 47451511b5
1 changed files with 13 additions and 13 deletions

View File

@ -154,7 +154,17 @@
}
};
// 9. Setup function to configure event handlers
// 9. Helper function for touch event
let touchInText = function(e, boxItem, boxKey) {
calcBoxSize(boxItem);
const pos = calcBoxPos(boxKey);
return e.x >= pos.x1 &&
e.x <= pos.x2 &&
e.y >= pos.y1 &&
e.y <= pos.y2;
};
// 10. Setup function to configure event handlers
let setup = function() {
// Define the touchHandler function
touchHandler = function(zone, e) {
@ -208,13 +218,13 @@
Bangle.setUI({
mode : "clock",
remove : function() {
// remove the event handlers when the app should be removed
// Remove event handlers, stop draw timer, remove custom font if used
Bangle.removeListener('touch', touchHandler);
Bangle.removeListener('drag', dragHandler);
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = undefined;
delete Graphics.prototype.setFontBrunoAce;
g.drawString = g_drawString;
g.drawString = g_drawString; // Return to original without outlines
require("widget_utils").show();
}
});
@ -222,16 +232,6 @@
draw(boxes);
};
// 10. Helper function for touch event
let touchInText = function(e, boxItem, boxKey) {
calcBoxSize(boxItem);
const pos = calcBoxPos(boxKey);
return e.x >= pos.x1 &&
e.x <= pos.x2 &&
e.y >= pos.y1 &&
e.y <= pos.y2;
};
// 11. Main execution part
Bangle.loadWidgets();
require("widget_utils").swipeOn();