Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E_showMenu_/E_showScroller_Q3: forward touch event #2565

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

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

2v24 : Bangle.js2: Add 'Bangle.touchRd()', 'Bangle.touchWr()'
Bangle.js2: After Bangle.showTestScreen, put Bangle.js into a hard off state (not soft off)
Expand Down
5 changes: 5 additions & 0 deletions libs/banglejs/jswrap_bangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -5932,6 +5932,10 @@ On Bangle.js there are a few additions over the standard `graphical_menu`:
menu is removed
* (Bangle.js 2) `scroll : int` - an integer specifying how much the initial
menu should be scrolled by
* (Bangle.js 2) The mapped functions can consider the touch event that interacted with the entry:
`"Entry" : function(touch) { ... }`
* This is also true of `onchange` mapped functions in entry objects:
`onchange : (value, touch) => { ... }`
* The object returned by `E.showMenu` contains:
* (Bangle.js 2) `scroller` - the object returned by `E.showScroller` -
`scroller.scroll` returns the amount the menu is currently scrolled by
Expand Down Expand Up @@ -6074,6 +6078,7 @@ Supply an object containing:
draw : function(idx, rect) { ... }
// a function to call when the item is selected, touch parameter is only relevant
// for Bangle.js 2 and contains the coordinates touched inside the selected item
// as well as the type of the touch - see `Bangle.touch`.
select : function(idx, touch) { ... }
// optional function to be called when 'back' is tapped
back : function() { ...}
Expand Down
8 changes: 4 additions & 4 deletions libs/js/banglejs/E_showMenu_Q3.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,19 @@
l = g.setFont("6x15").wrapString(title,r.w-pad);
g.setFontAlign(-1,0).drawString(l.join("\n"), r.x+12, r.y+H/2);
},
select : function(idx) {
select : function(idx, touch) {
if (idx<0) return back&&back(); // title
var item = menu[keys[idx]];
Bangle.buzz(20);
if ("function" == typeof item) item();
if ("function" == typeof item) item(touch);
else if ("object" == typeof item) {
// if a bool, just toggle it
if ("number" == typeof item.value) {
showSubMenu(item, keys[idx]);
} else {
// if a bool, just toggle it
if ("boolean"==typeof item.value)
item.value=!item.value;
if (item.onchange) item.onchange(item.value);
if (item.onchange) item.onchange(item.value, touch);
thyttan marked this conversation as resolved.
Show resolved Hide resolved
if (l.scroller.isActive()) l.scroller.drawItem(idx);
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/js/banglejs/E_showScroller_Q3.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Bangle.setUI({
}
if ((menuScrollMin<0 || i>=0) && i<options.c){
//console.log("Press ",e.y,i,yInElement);
options.select(i, {x:e.x, y:yInElement});
options.select(i, {x:e.x, y:yInElement, type:e.type});
}
}
});
Expand Down
Loading