mirror of https://github.com/espruino/BangleApps
clock_info: permit focus/blur to cancel a redraw
parent
9c16fa6c79
commit
736b9f0433
|
@ -287,22 +287,21 @@ exports.addInteractive = function(menu, options) {
|
|||
const blur = () => {
|
||||
options.focus=false;
|
||||
delete Bangle.CLKINFO_FOCUS;
|
||||
options.redraw();
|
||||
const itm = menu[options.menuA].items[options.menuB];
|
||||
if (itm.blur) itm.blur(options);
|
||||
let redraw = true;
|
||||
if (itm.blur && itm.blur(options) === false)
|
||||
redraw = false;
|
||||
if (redraw) options.redraw();
|
||||
};
|
||||
const focus = (redraw) => {
|
||||
let shown = false;
|
||||
if (!options.focus) {
|
||||
options.focus=true;
|
||||
Bangle.CLKINFO_FOCUS=true;
|
||||
shown = true;
|
||||
const itm = menu[options.menuA].items[options.menuB];
|
||||
if (itm.focus && itm.focus(options) === false)
|
||||
redraw = false;
|
||||
}
|
||||
if (redraw) options.redraw();
|
||||
if (shown) {
|
||||
const itm = menu[options.menuA].items[options.menuB];
|
||||
if (itm.focus) itm.focus(options);
|
||||
}
|
||||
};
|
||||
let touchHandler, lockHandler;
|
||||
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
||||
|
|
|
@ -15,8 +15,8 @@ declare module ClockInfo {
|
|||
hide(options: InteractiveOptions): void,
|
||||
on(what: "redraw", cb: () => void): void, // extending from Object
|
||||
run?(options: InteractiveOptions): void,
|
||||
focus?(options: InteractiveOptions): void,
|
||||
blur?(options: InteractiveOptions): void,
|
||||
focus?(options: InteractiveOptions): void | false,
|
||||
blur?(options: InteractiveOptions): void | false,
|
||||
} & (
|
||||
{
|
||||
hasRange: true,
|
||||
|
|
Loading…
Reference in New Issue