Skip to content

Commit 8b2e5a5

Browse files
committed
Bangle.js2: Fix issue using touch handler with Bangle.setUI({mode:"updown",...}) (fix #2648)
1 parent f3b5e0d commit 8b2e5a5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Bangle.js2: Adjust accelerometer axes for HRM algorithm to more closely match the datasheet
77
nRF52: Add NRF/BluetoothRemoteGATTServer.updateConnection for setting the phy
88
Bangle.js2: Add Bangle.setOptions({hrmStaticSampleTime})
9+
Bangle.js2: Fix issue using touch handler with Bangle.setUI({mode:"updown",...}) (fix #2648)
910

1011
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
1112
nRF5x: Remove handlers from our handlers array when a device is disconnected

libs/js/banglejs/Bangle_setUI_Q3.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if (!mode) throw new Error("Missing mode in setUI({...})");
77
}
88
var hadBackWidget = false;
9-
if (global.WIDGETS && WIDGETS.back) {
9+
if (global.WIDGETS && WIDGETS.back) {
1010
hadBackWidget = true; // if we had a back widget already, don't redraw at the end
1111
WIDGETS.back.remove(options.back); // only redraw when removing if we don't have options.back
1212
}
@@ -26,6 +26,10 @@
2626
Bangle.removeListener("touch", Bangle.touchHandler);
2727
delete Bangle.touchHandler;
2828
}
29+
if (Bangle.touchHandler2) {
30+
Bangle.removeListener("touch", Bangle.touchHandler2);
31+
delete Bangle.touchHandler2;
32+
}
2933
delete Bangle.uiRedraw;
3034
delete Bangle.CLOCK;
3135
if (Bangle.uiRemove) {
@@ -99,8 +103,13 @@
99103
throw new Error("Unknown UI mode "+E.toJS(mode));
100104
if (options.clock) Bangle.CLOCK=1;
101105
if (options.touch) {
102-
Bangle.touchHandler = options.touch;
103-
Bangle.on("touch", Bangle.touchHandler);
106+
if (Bangle.touchHandler) { // don't overwrite existing touch handler if using updown/etc (#2648)
107+
Bangle.touchHandler2 = options.touch;
108+
Bangle.on("touch", Bangle.touchHandler2);
109+
} else {
110+
Bangle.touchHandler = options.touch;
111+
Bangle.on("touch", Bangle.touchHandler);
112+
}
104113
}
105114
if (options.drag) {
106115
Bangle.dragHandler = options.drag;
190 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)