Skip to content

Commit ce663a1

Browse files
authored
Merge pull request #2565 from thyttan/showscroller-q3
E_showMenu_/E_showScroller_Q3: forward touch event
2 parents 3788fbb + 28375c8 commit ce663a1

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

ChangeLog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
Jolt.js: Increase Storage area from 40kb to 400kb
2525
nRF5x: Don't add BLE UART write events into the input buffer
2626
ESP32: Timers are now turned off when requested - digitalPulse/soft pwm/writeAtTime more accurate
27-
Bangle.js: Remove debug log messages from E.showScroller
27+
Bangle.js2: Remove debug log messages from E.showScroller
2828
STM32F4: Update stm32f4xx_ll_usb to fix over-buffered USB CDC tx after being woken from deep sleep
2929
Waveform: Add 'npin' option to allow +/- output on two pins
3030
Waveform: Add ability to play directly from Storage
@@ -41,6 +41,7 @@
4141
Bangle.js: E.showMenu no longer sends the internal `l` menu object as argument when running the callback function.
4242
Bangle.js2: GPS request RMC packet automatically (so GPS speed/time work even without AGPS) (fix #2354)
4343
Bangle.js2: GPS now detects binary CASIC packets and splits them into their own GPS-raw event
44+
Bangle.js2: Pass the modified touch event on through both E.showScroller and E.showMenu (to enable more complex interaction with menus).
4445

4546
2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
4647
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)

libs/banglejs/jswrap_bangle.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5932,6 +5932,10 @@ On Bangle.js there are a few additions over the standard `graphical_menu`:
59325932
menu is removed
59335933
* (Bangle.js 2) `scroll : int` - an integer specifying how much the initial
59345934
menu should be scrolled by
5935+
* (Bangle.js 2) The mapped functions can consider the touch event that interacted with the entry:
5936+
`"Entry" : function(touch) { ... }`
5937+
* This is also true of `onchange` mapped functions in entry objects:
5938+
`onchange : (value, touch) => { ... }`
59355939
* The object returned by `E.showMenu` contains:
59365940
* (Bangle.js 2) `scroller` - the object returned by `E.showScroller` -
59375941
`scroller.scroll` returns the amount the menu is currently scrolled by
@@ -6074,6 +6078,7 @@ Supply an object containing:
60746078
draw : function(idx, rect) { ... }
60756079
// a function to call when the item is selected, touch parameter is only relevant
60766080
// for Bangle.js 2 and contains the coordinates touched inside the selected item
6081+
// as well as the type of the touch - see `Bangle.touch`.
60776082
select : function(idx, touch) { ... }
60786083
// optional function to be called when 'back' is tapped
60796084
back : function() { ...}

libs/js/banglejs/E_showMenu_Q3.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,19 @@
133133
l = g.setFont("6x15").wrapString(title,r.w-pad);
134134
g.setFontAlign(-1,0).drawString(l.join("\n"), r.x+12, r.y+H/2);
135135
},
136-
select : function(idx) {
136+
select : function(idx, touch) {
137137
if (idx<0) return back&&back(); // title
138138
var item = menu[keys[idx]];
139139
Bangle.buzz(20);
140-
if ("function" == typeof item) item();
140+
if ("function" == typeof item) item(touch);
141141
else if ("object" == typeof item) {
142-
// if a bool, just toggle it
143142
if ("number" == typeof item.value) {
144143
showSubMenu(item, keys[idx]);
145144
} else {
145+
// if a bool, just toggle it
146146
if ("boolean"==typeof item.value)
147147
item.value=!item.value;
148-
if (item.onchange) item.onchange(item.value);
148+
if (item.onchange) item.onchange(item.value, touch);
149149
if (l.scroller.isActive()) l.scroller.drawItem(idx);
150150
}
151151
}

libs/js/banglejs/E_showScroller_Q3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Bangle.setUI({
8282
}
8383
if ((menuScrollMin<0 || i>=0) && i<options.c){
8484
//console.log("Press ",e.y,i,yInElement);
85-
options.select(i, {x:e.x, y:yInElement});
85+
options.select(i, {x:e.x, y:yInElement, type:e.type});
8686
}
8787
}
8888
});

0 commit comments

Comments
 (0)