Skip to content

Commit bf293ba

Browse files
committed
Bangle.js2: Menus now buzz when back button pressed or icon tapped (fix #2642)
1 parent 8b2e5a5 commit bf293ba

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
nRF52: Add NRF/BluetoothRemoteGATTServer.updateConnection for setting the phy
88
Bangle.js2: Add Bangle.setOptions({hrmStaticSampleTime})
99
Bangle.js2: Fix issue using touch handler with Bangle.setUI({mode:"updown",...}) (fix #2648)
10+
Bangle.js2: Menus now buzz when back button pressed or icon tapped (fix #2642)
1011

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

libs/js/banglejs/Bangle_setUI_Q3.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
(function(mode, cb) {
2-
var options = {};
2+
var options = {},
3+
hadBackWidget = false,
4+
b = ()=>Bangle.buzz(30);
35
if ("object"==typeof mode) {
46
options = mode;
57
mode = options.mode;
68
if (!mode) throw new Error("Missing mode in setUI({...})");
79
}
8-
var hadBackWidget = false;
910
if (global.WIDGETS && WIDGETS.back) {
1011
hadBackWidget = true; // if we had a back widget already, don't redraw at the end
1112
WIDGETS.back.remove(options.back); // only redraw when removing if we don't have options.back
@@ -39,9 +40,7 @@
3940
}
4041
g.reset();// reset graphics state, just in case
4142
if (!mode) return;
42-
function b() {
43-
try{Bangle.buzz(30);}catch(e){}
44-
}
43+
4544
if (mode=="updown") {
4645
if (options.drag) throw new Error("Custom drag handler not supported in mode updown!")
4746
var dy = 0;
@@ -103,13 +102,10 @@
103102
throw new Error("Unknown UI mode "+E.toJS(mode));
104103
if (options.clock) Bangle.CLOCK=1;
105104
if (options.touch) {
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-
}
105+
if (Bangle.touchHandler) // don't overwrite existing touch handler if using updown/etc (#2648)
106+
Bangle.on("touch", Bangle.touchHandler2 = options.touch);
107+
else
108+
Bangle.on("touch", Bangle.touchHandler = options.touch);
113109
}
114110
if (options.drag) {
115111
Bangle.dragHandler = options.drag;
@@ -131,7 +127,7 @@
131127
if (Bangle.btnWatches===undefined)
132128
Bangle.btnWatches = [ setWatch(function() {
133129
Bangle.btnWatches = undefined; // watch doesn't repeat
134-
options.back();
130+
b().then(() => options.back());
135131
}, BTN1, {edge:"rising"}) ];
136132
// if we have widgets loaded *and* visible at the top, add a back widget (see #3788)
137133
if (global.WIDGETS && Bangle.appRect.y) {
@@ -140,7 +136,7 @@
140136
if (e.y<36 && e.x<48) {
141137
e.handled = true;
142138
E.stopEventPropagation(); // stop subsequent touch handlers from being called
143-
options.back();
139+
b().then(() => options.back());
144140
}
145141
};
146142
Bangle.prependListener("touch", touchHandler);
33 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)