From 5b83d75c953a3b96fc3de64f2596d3505158321d Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Fri, 22 Aug 2025 23:27:33 +0200 Subject: [PATCH 1/8] E_showPrompt_Q3: allow long press actions as proposed at https://github.com/espruino/BangleApps/issues/3915#issuecomment-3212066440 --- libs/js/banglejs/E_showPrompt_Q3.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/js/banglejs/E_showPrompt_Q3.js b/libs/js/banglejs/E_showPrompt_Q3.js index e998357e0..1b856b116 100644 --- a/libs/js/banglejs/E_showPrompt_Q3.js +++ b/libs/js/banglejs/E_showPrompt_Q3.js @@ -64,6 +64,9 @@ draw(i); // highlighted button g.flip(); // write to screen E.showPrompt(); // remove + if (e.type===2 /*long press*/ && options.buttonsLong && options.buttonsLong[btns[i]]) { + resolve(options.buttonsLong[btns[i]]); + } resolve(options.buttons[btns[i]]); } }); @@ -76,4 +79,4 @@ }; Bangle.setUI(ui); }); -}) \ No newline at end of file +}) From 79723567b636168619e06adfc101dfdd3b2c2700 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Wed, 27 Aug 2025 22:30:00 +0200 Subject: [PATCH 2/8] E_showPrompt_Q3: improve readability by adding `else` --- libs/js/banglejs/E_showPrompt_Q3.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/js/banglejs/E_showPrompt_Q3.js b/libs/js/banglejs/E_showPrompt_Q3.js index 1b856b116..6fbd9b38c 100644 --- a/libs/js/banglejs/E_showPrompt_Q3.js +++ b/libs/js/banglejs/E_showPrompt_Q3.js @@ -64,10 +64,10 @@ draw(i); // highlighted button g.flip(); // write to screen E.showPrompt(); // remove - if (e.type===2 /*long press*/ && options.buttonsLong && options.buttonsLong[btns[i]]) { + if (e.type===2 /*long press*/ && options.buttonsLong && options.buttonsLong[btns[i]]) resolve(options.buttonsLong[btns[i]]); - } - resolve(options.buttons[btns[i]]); + else + resolve(options.buttons[btns[i]]); } }); }}; From 86003a6cfbf75db0704cb1dad318edfa574cf7bd Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Wed, 27 Aug 2025 23:25:26 +0200 Subject: [PATCH 3/8] showPrompt: modify docs --- libs/banglejs/jswrap_bangle.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/banglejs/jswrap_bangle.c b/libs/banglejs/jswrap_bangle.c index d7d460195..1670f6522 100644 --- a/libs/banglejs/jswrap_bangle.c +++ b/libs/banglejs/jswrap_bangle.c @@ -6113,6 +6113,7 @@ The second `options` argument can contain: { title: "Hello", // optional Title buttons : {"Ok":true,"Cancel":false}, // optional list of button text & return value + buttonsLong : {"Ok":2,"Cancel":"Cancel"}, // Bangle.js2: optional subset of buttons that should also have a specific long press action img: "image_string" // optional image string to draw remove: function() { } // Bangle.js: optional function to be called when the prompt is removed# buttonHeight : 30, // Bangle.js2: optional height to force the buttons to be From d9f34943a4a3da53ace48917cc1934536b18e263 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Wed, 27 Aug 2025 23:40:53 +0200 Subject: [PATCH 4/8] showPrompt: add to ChangeLog --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index cfde99f2f..11f69397d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + : Bangle.js2: Add long press button actions to `showPrompt` (#2656) : Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]` Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636) nRF52: Add 'slaveLatency' option to BluetoothRemoteGATTServer.connect, default changed from 2 to 4 From 8a5b7b36deb8a358f2a70c6627c5dd7ec44c2230 Mon Sep 17 00:00:00 2001 From: thyttan <97237430+thyttan@users.noreply.github.com> Date: Thu, 28 Aug 2025 21:43:02 +0200 Subject: [PATCH 5/8] E_showPrompt_Q3: permit passing falsy values Author: @bobrippling Co-authored-by: Rob Pilling --- libs/js/banglejs/E_showPrompt_Q3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/js/banglejs/E_showPrompt_Q3.js b/libs/js/banglejs/E_showPrompt_Q3.js index 6fbd9b38c..434cd2501 100644 --- a/libs/js/banglejs/E_showPrompt_Q3.js +++ b/libs/js/banglejs/E_showPrompt_Q3.js @@ -64,7 +64,7 @@ draw(i); // highlighted button g.flip(); // write to screen E.showPrompt(); // remove - if (e.type===2 /*long press*/ && options.buttonsLong && options.buttonsLong[btns[i]]) + if (e.type===2 /*long press*/ && options.buttonsLong && btns[i] in options.buttonsLong) resolve(options.buttonsLong[btns[i]]); else resolve(options.buttons[btns[i]]); From 473e8bbabd79979ec0bb68e085bdee62de74b44a Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Thu, 28 Aug 2025 21:46:36 +0200 Subject: [PATCH 6/8] showPrompt: update typescript author: @bobrippling --- libs/banglejs/jswrap_bangle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/banglejs/jswrap_bangle.c b/libs/banglejs/jswrap_bangle.c index 1670f6522..355921c8f 100644 --- a/libs/banglejs/jswrap_bangle.c +++ b/libs/banglejs/jswrap_bangle.c @@ -6073,7 +6073,7 @@ E.showMessage("Lots of text will wrap automatically",{ "return" : ["JsVar","A promise that is resolved when 'Ok' is pressed"], "ifdef" : "BANGLEJS", "typescript" : [ - "showPrompt(message: string, options?: { title?: string, buttons?: { [key: string]: T }, buttonHeight?: number, image?: string, remove?: () => void }): Promise;", + "showPrompt(message: string, options?: { title?: string, buttons?: { [key: string]: T }, buttonsLong?: { [key: string]: T }, buttonHeight?: number, image?: string, remove?: () => void }): Promise;", "showPrompt(): void;" ] } From 836b00215583ddb36fa7368e576cc692101abda6 Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.com> Date: Thu, 28 Aug 2025 22:16:23 +0200 Subject: [PATCH 7/8] E_showPrompt_Q3: update minified code Minification details: compilation_level = SIMPLE_OPTIMIZATIONS language_out = STABLE Using offline closure compiler --- libs/js/banglejs/E_showPrompt_Q3.min.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/js/banglejs/E_showPrompt_Q3.min.js b/libs/js/banglejs/E_showPrompt_Q3.min.js index 49e38d893..33e0e4193 100644 --- a/libs/js/banglejs/E_showPrompt_Q3.min.js +++ b/libs/js/banglejs/E_showPrompt_Q3.min.js @@ -1,2 +1,2 @@ -(ª(z,a){ªt(q){g.reset().setFontAlign(Ó,Ó);¬h=Bangle.appRect,f=h.y,b=h.w,c=g.findFont(a.title "",{w:b-Ô,wrap:Ô,max:Ô});c.text?(g.setColor(g.theme.fgH).setBgColor(g.theme.bgH).clearRect(Ó,f,b-Ô,f+Ô+c.h).drawString(c.text,b/Ô,f+Ô+c.h/Ô),f–c.h+Ô):f–Ô;¬l=Ó|Ñ0123233[k.length],v=Math.ceil(k.length/l),w=(b-Ô)/l,n=a.buttonHeight (Ô6 buttons);¬x;g.reset().clearRect(Bangle.appRect);£(!z)«Bangle.setUI(),Promise.resolve();t();«¸Promise(q¢{¬h={mode:Ñcustom,remove:a.remove,redraw:t,back:a.back,touch:(f,b)¢{x.forEach((c,l)¢{b.x‘c.x1žb.xŽc.x2žb.y‘c.y1žb.yŽc.y2ž!b.hitž(b.hit=!Ó,t(l),g.flip(),E.showPrompt(),q(a.buttons[k[l]]))})}};ÔŒk.length a.back (h.btn=()¢{t(Ó);g.flip();E.showPrompt();q(a.buttons[k[Ó]])});Bangle.setUI(h)})}) \ No newline at end of file +(ª(z,a){ªt(n){g.reset().setFontAlign(Ó,Ó);¬l=Bangle.appRect,f=l.y,b=l.w,c=g.findFont(a.title "",{w:b-Ô,wrap:Ô,max:Ô});c.text?(g.setColor(g.theme.fgH).setBgColor(g.theme.bgH).clearRect(Ó,f,b-Ô,f+Ô+c.h).drawString(c.text,b/Ô,f+Ô+c.h/Ô),f–c.h+Ô):f–Ô;¬k=Ó|Ñ0123233[h.length],v=Math.ceil(h.length/k),w=(b-Ô)/k,p=a.buttonHeight (Ô6 buttons);¬x;g.reset().clearRect(Bangle.appRect);£(!z)«Bangle.setUI(),Promise.resolve();t();«¸Promise(n¢{¬l={mode:Ñcustom,remove:a.remove,redraw:t,back:a.back,touch:(f,b)¢{x.forEach((c,k)¢{b.x‘c.x1žb.xŽc.x2žb.y‘c.y1žb.yŽc.y2ž!b.hitž(b.hit=!Ó,t(k),g.flip(),E.showPrompt(),Ô‹b.typeža.buttonsLongžh[k]¹a.buttonsLong?n(a.buttonsLong[h[k]]):n(a.buttons[h[k]]))})}};ÔŒh.length a.back (l.btn=()¢{t(Ó);g.flip();E.showPrompt();n(a.buttons[h[Ó]])});Bangle.setUI(l)})}) \ No newline at end of file From 77909d929fb8240fdd900b5d4a2cdca1277bd7dd Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Fri, 29 Aug 2025 11:50:56 +0100 Subject: [PATCH 8/8] Update ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 11f69397d..ff6c20c84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,3 @@ - : Bangle.js2: Add long press button actions to `showPrompt` (#2656) : Add `E.internal` as a way to access the 'hidden root' containing Espruino internal variables that previously needed `global["\xff"]` Bangle.js: Fix back handler not removed when using E.setUI with a back button but without widgets (#2636) nRF52: Add 'slaveLatency' option to BluetoothRemoteGATTServer.connect, default changed from 2 to 4 @@ -11,6 +10,7 @@ Bangle.js2: Menus now buzz when back button pressed or icon tapped (fix #2642) JIT: When referencing a built-in member function of a built-in (Math.*, E.*, PIN_NAME.*, etc) include address rather than looking up (#2398) nRF52 Central: Lower min connection interval from 20->7.5ms, max 200->1000ms (allows some extra devices to be connected to) + Bangle.js2: Add optional long press button actions to `showPrompt` (#2656) 2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics nRF5x: Remove handlers from our handlers array when a device is disconnected