Skip to content

Commit b99bc3e

Browse files
author
Corwin Kerr
committed
clock_info: Use ensure_blur as public function in options
1 parent 86e6f86 commit b99bc3e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

apps/clock_info/lib.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,15 +326,16 @@ exports.addInteractive = function(menu, options) {
326326
const blur = () => {
327327
options.focus=false;
328328
Bangle.CLKINFO_FOCUS--;
329-
// if (Bangle.CLKINFO_FOCUS < 0) Bangle.CLKINFO_FOCUS = 0;
330329
const itm = menu[options.menuA].items[options.menuB];
331330
let redraw = true;
332331
if (itm.blur && itm.blur(options) === false)
333332
redraw = false;
334333
if (redraw) options.redraw();
335334
};
336-
// better to only call blur when we know it's focused. Maybe we can rename force_blur to ensure_blur.
337-
options.force_blur = blur;
335+
// better to only call blur when we know it's focused. Could reuse this logic in this file
336+
options.ensure_blur = () => {
337+
if (options.focus) blur()
338+
}
338339
const focus = () => {
339340
let redraw = true;
340341
Bangle.CLKINFO_FOCUS = (0 | Bangle.CLKINFO_FOCUS) + 1;

apps/widclkinfo/widget.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
}
5858
}.init();
5959

60+
// We make clock info touch area active on the start of the animation
6061
Bangle.on("widgets-start-show", () => {
6162
var wi = WIDGETS["clkinfo"];
6263
if (wi) {
@@ -76,7 +77,7 @@
7677
Bangle.on("widgets-start-hide", () => {
7778
var wi = WIDGETS["clkinfo"];
7879
if (wi) {
79-
if (wi.clockInfoMenu.focus) wi.clockInfoMenu.blur();
80+
wi.clockInfoMenu.ensure_blur(); // let user see defocus cue before hiding
8081
wi.clockInfoMenu.y = -24;
8182
wi.draw(wi);
8283
}
@@ -85,7 +86,7 @@
8586
Bangle.on("widgets-hidden", () => {
8687
var wi = WIDGETS["clkinfo"];
8788
if (wi) {
88-
if (wi.clockInfoMenu.focus) wi.clockInfoMenu.blur();
89+
wi.clockInfoMenu.ensure_blur();
8990
wi.clockInfoMenu.y = -24;
9091
wi.draw(wi);
9192
}

0 commit comments

Comments
 (0)