clock_info: permit focus/blur to cancel a redraw
parent
9c16fa6c79
commit
736b9f0433
|
|
@ -287,22 +287,21 @@ exports.addInteractive = function(menu, options) {
|
||||||
const blur = () => {
|
const blur = () => {
|
||||||
options.focus=false;
|
options.focus=false;
|
||||||
delete Bangle.CLKINFO_FOCUS;
|
delete Bangle.CLKINFO_FOCUS;
|
||||||
options.redraw();
|
|
||||||
const itm = menu[options.menuA].items[options.menuB];
|
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) => {
|
const focus = (redraw) => {
|
||||||
let shown = false;
|
|
||||||
if (!options.focus) {
|
if (!options.focus) {
|
||||||
options.focus=true;
|
options.focus=true;
|
||||||
Bangle.CLKINFO_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 (redraw) options.redraw();
|
||||||
if (shown) {
|
|
||||||
const itm = menu[options.menuA].items[options.menuB];
|
|
||||||
if (itm.focus) itm.focus(options);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let touchHandler, lockHandler;
|
let touchHandler, lockHandler;
|
||||||
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
if (options.x!==undefined && options.y!==undefined && options.w && options.h) {
|
||||||
|
|
|
||||||
|
|
@ -15,8 +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,
|
focus?(options: InteractiveOptions): void | false,
|
||||||
blur?(options: InteractiveOptions): void,
|
blur?(options: InteractiveOptions): void | false,
|
||||||
} & (
|
} & (
|
||||||
{
|
{
|
||||||
hasRange: true,
|
hasRange: true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue