Skip to content

Commit 0162391

Browse files
authored
Merge pull request #2656 from thyttan/showPrompt-long-press
E_showPrompt_Q3: allow long press actions
2 parents 5acf953 + 77909d9 commit 0162391

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Bangle.js2: Menus now buzz when back button pressed or icon tapped (fix #2642)
1111
JIT: When referencing a built-in member function of a built-in (Math.*, E.*, PIN_NAME.*, etc) include address rather than looking up (#2398)
1212
nRF52 Central: Lower min connection interval from 20->7.5ms, max 200->1000ms (allows some extra devices to be connected to)
13+
Bangle.js2: Add optional long press button actions to `showPrompt` (#2656)
1314

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

libs/banglejs/jswrap_bangle.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6073,7 +6073,7 @@ E.showMessage("Lots of text will wrap automatically",{
60736073
"return" : ["JsVar","A promise that is resolved when 'Ok' is pressed"],
60746074
"ifdef" : "BANGLEJS",
60756075
"typescript" : [
6076-
"showPrompt<T = boolean>(message: string, options?: { title?: string, buttons?: { [key: string]: T }, buttonHeight?: number, image?: string, remove?: () => void }): Promise<T>;",
6076+
"showPrompt<T = boolean>(message: string, options?: { title?: string, buttons?: { [key: string]: T }, buttonsLong?: { [key: string]: T }, buttonHeight?: number, image?: string, remove?: () => void }): Promise<T>;",
60776077
"showPrompt(): void;"
60786078
]
60796079
}
@@ -6113,6 +6113,7 @@ The second `options` argument can contain:
61136113
{
61146114
title: "Hello", // optional Title
61156115
buttons : {"Ok":true,"Cancel":false}, // optional list of button text & return value
6116+
buttonsLong : {"Ok":2,"Cancel":"Cancel"}, // Bangle.js2: optional subset of buttons that should also have a specific long press action
61166117
img: "image_string" // optional image string to draw
61176118
remove: function() { } // Bangle.js: optional function to be called when the prompt is removed#
61186119
buttonHeight : 30, // Bangle.js2: optional height to force the buttons to be

libs/js/banglejs/E_showPrompt_Q3.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@
6464
draw(i); // highlighted button
6565
g.flip(); // write to screen
6666
E.showPrompt(); // remove
67-
resolve(options.buttons[btns[i]]);
67+
if (e.type===2 /*long press*/ && options.buttonsLong && btns[i] in options.buttonsLong)
68+
resolve(options.buttonsLong[btns[i]]);
69+
else
70+
resolve(options.buttons[btns[i]]);
6871
}
6972
});
7073
}};
@@ -76,4 +79,4 @@
7679
};
7780
Bangle.setUI(ui);
7881
});
79-
})
82+
})

libs/js/banglejs/E_showPrompt_Q3.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)