mirror of https://github.com/espruino/BangleApps
clock_info: pass options through to show(), hide() & run()
parent
a667fc8061
commit
30d1bc7c4c
|
@ -234,7 +234,7 @@ exports.addInteractive = function(menu, options) {
|
||||||
options.redrawHandler = ()=>drawItem(itm);
|
options.redrawHandler = ()=>drawItem(itm);
|
||||||
itm.on('redraw', options.redrawHandler);
|
itm.on('redraw', options.redrawHandler);
|
||||||
itm.uses = (0|itm.uses)+1;
|
itm.uses = (0|itm.uses)+1;
|
||||||
if (itm.uses==1) itm.show();
|
if (itm.uses==1) itm.show(options);
|
||||||
itm.emit("redraw");
|
itm.emit("redraw");
|
||||||
}
|
}
|
||||||
function menuHideItem(itm) {
|
function menuHideItem(itm) {
|
||||||
|
@ -242,7 +242,7 @@ exports.addInteractive = function(menu, options) {
|
||||||
delete options.redrawHandler;
|
delete options.redrawHandler;
|
||||||
itm.uses--;
|
itm.uses--;
|
||||||
if (!itm.uses)
|
if (!itm.uses)
|
||||||
itm.hide();
|
itm.hide(options);
|
||||||
}
|
}
|
||||||
// handling for swipe between menu items
|
// handling for swipe between menu items
|
||||||
function swipeHandler(lr,ud){
|
function swipeHandler(lr,ud){
|
||||||
|
@ -307,7 +307,7 @@ exports.addInteractive = function(menu, options) {
|
||||||
focus(true);
|
focus(true);
|
||||||
} else if (menu[options.menuA].items[options.menuB].run) {
|
} else if (menu[options.menuA].items[options.menuB].run) {
|
||||||
Bangle.buzz(100, 0.7);
|
Bangle.buzz(100, 0.7);
|
||||||
menu[options.menuA].items[options.menuB].run(); // allow tap on an item to run it (eg home assistant)
|
menu[options.menuA].items[options.menuB].run(options); // allow tap on an item to run it (eg home assistant)
|
||||||
} else {
|
} else {
|
||||||
focus();
|
focus();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,10 @@ declare module ClockInfo {
|
||||||
|
|
||||||
type MenuItem = {
|
type MenuItem = {
|
||||||
name: string,
|
name: string,
|
||||||
show(): void,
|
show(options: InteractiveOptions): void,
|
||||||
hide(): void,
|
hide(options: InteractiveOptions): void,
|
||||||
on(what: "redraw", cb: () => void): void, // extending from Object
|
on(what: "redraw", cb: () => void): void, // extending from Object
|
||||||
run?(): void,
|
run?(options: InteractiveOptions): void,
|
||||||
} & (
|
} & (
|
||||||
{
|
{
|
||||||
hasRange: true,
|
hasRange: true,
|
||||||
|
|
Loading…
Reference in New Issue