clock_info: add focus and unfocus to item

pull/3234/head
Rob Pilling 2024-03-11 08:42:45 +00:00
parent 30d1bc7c4c
commit 8f86d9297b
2 changed files with 10 additions and 2 deletions

View File

@ -288,10 +288,16 @@ exports.addInteractive = function(menu, options) {
options.focus=false; options.focus=false;
delete Bangle.CLKINFO_FOCUS; delete Bangle.CLKINFO_FOCUS;
options.redraw(); options.redraw();
const itm = menu[options.menuA].items[options.menuB];
if (itm.unfocus) itm.unfocus(options);
}; };
const focus = (redraw) => { const focus = (redraw) => {
options.focus=true; if (!options.focus) {
Bangle.CLKINFO_FOCUS=true; options.focus=true;
Bangle.CLKINFO_FOCUS=true;
const itm = menu[options.menuA].items[options.menuB];
if (itm.focus) itm.focus(options);
}
if (redraw) options.redraw(); if (redraw) options.redraw();
}; };
let touchHandler, lockHandler; let touchHandler, lockHandler;

View File

@ -15,6 +15,8 @@ declare module ClockInfo {
hide(options: InteractiveOptions): void, hide(options: InteractiveOptions): void,
on(what: "redraw", cb: () => void): void, // extending from Object on(what: "redraw", cb: () => void): void, // extending from Object
run?(options: InteractiveOptions): void, run?(options: InteractiveOptions): void,
focus?(options: InteractiveOptions): void,
unfocus?(options: InteractiveOptions): void,
} & ( } & (
{ {
hasRange: true, hasRange: true,