promenu: fix double-render from having two callbacks with "updown"
parent
c0545cf2c2
commit
2c51bc80e5
|
|
@ -126,7 +126,6 @@ E.showMenu = (function (items) {
|
||||||
nameScroll_1 = 0;
|
nameScroll_1 = 0;
|
||||||
}, 300, name, v, item, idx, x, iy);
|
}, 300, name, v, item, idx, x, iy);
|
||||||
}
|
}
|
||||||
g.setColor(g.theme.fg);
|
|
||||||
iy += fontHeight;
|
iy += fontHeight;
|
||||||
idx++;
|
idx++;
|
||||||
};
|
};
|
||||||
|
|
@ -219,17 +218,19 @@ E.showMenu = (function (items) {
|
||||||
if (nameScroller)
|
if (nameScroller)
|
||||||
clearInterval(nameScroller);
|
clearInterval(nameScroller);
|
||||||
Bangle.removeListener("swipe", onSwipe);
|
Bangle.removeListener("swipe", onSwipe);
|
||||||
if (is2v26_27)
|
if (setUITouch)
|
||||||
Bangle.removeListener("touch", touchcb);
|
Bangle.removeListener("touch", touchcb);
|
||||||
(_a = options.remove) === null || _a === void 0 ? void 0 : _a.call(options);
|
(_a = options.remove) === null || _a === void 0 ? void 0 : _a.call(options);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
var is2v26_27 = process.env.VERSION === "2v26" || process.env.VERSION === "2v27";
|
var setUITouch = process.env.VERSION >= "2v26";
|
||||||
if (!is2v26_27) {
|
if (!setUITouch) {
|
||||||
uiopts.touch = touchcb;
|
uiopts.touch = touchcb;
|
||||||
}
|
}
|
||||||
Bangle.setUI(uiopts, cb);
|
Bangle.setUI(uiopts, cb);
|
||||||
if (is2v26_27) {
|
if (setUITouch) {
|
||||||
|
Bangle.removeListener("touch", Bangle.touchHandler);
|
||||||
|
delete Bangle.touchHandler;
|
||||||
Bangle.on("touch", touchcb);
|
Bangle.on("touch", touchcb);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
|
|
|
||||||
|
|
@ -269,24 +269,32 @@ E.showMenu = ((items?: Menu): MenuInstance | void => {
|
||||||
remove: () => {
|
remove: () => {
|
||||||
if (nameScroller) clearInterval(nameScroller);
|
if (nameScroller) clearInterval(nameScroller);
|
||||||
Bangle.removeListener("swipe", onSwipe);
|
Bangle.removeListener("swipe", onSwipe);
|
||||||
if(is2v26_27)
|
if(setUITouch)
|
||||||
Bangle.removeListener("touch", touchcb);
|
Bangle.removeListener("touch", touchcb);
|
||||||
options.remove?.();
|
options.remove?.();
|
||||||
},
|
},
|
||||||
} satisfies SetUIArg<"updown">;
|
} satisfies SetUIArg<"updown">;
|
||||||
|
|
||||||
const is2v26_27 = process.env.VERSION === "2v26" || process.env.VERSION === "2v27";
|
// does setUI install its own touch handler?
|
||||||
if (!is2v26_27) {
|
const setUITouch = process.env.VERSION >= "2v26";
|
||||||
// no need for workaround
|
if (!setUITouch) {
|
||||||
|
// old firmware, we can use its touch handler - no need for workaround
|
||||||
(uiopts as any).touch = touchcb;
|
(uiopts as any).touch = touchcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.setUI(uiopts, cb);
|
Bangle.setUI(uiopts, cb);
|
||||||
|
|
||||||
if(is2v26_27){
|
if(setUITouch){
|
||||||
// work around:
|
// new firmware, remove setUI's touch handler and use just our own to
|
||||||
|
// avoid `cb` drawing the menu (as part of setUI's touch handler)
|
||||||
|
// followed by us drawing the menu (as part of our touch handler)
|
||||||
|
//
|
||||||
|
// work around details:
|
||||||
// - https://github.com/espruino/Espruino/issues/2648
|
// - https://github.com/espruino/Espruino/issues/2648
|
||||||
// - https://github.com/orgs/espruino/discussions/7697#discussioncomment-13782299
|
// - https://github.com/orgs/espruino/discussions/7697#discussioncomment-13782299
|
||||||
|
Bangle.removeListener("touch", (Bangle as any).touchHandler);
|
||||||
|
delete (Bangle as any).touchHandler;
|
||||||
|
|
||||||
Bangle.on("touch", touchcb);
|
Bangle.on("touch", touchcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue