-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[widclkinfo] Keeps focus when widget_utils.swipeOn() #3680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
8d626dc
0d4d1b8
a906075
9ec6acc
73cf053
6cf3393
8ddfeab
37cc547
adfd5c8
6aa44dc
8e0d060
0d4234d
5579fd3
f213da4
ccb0350
7b598eb
612ffa3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
if (!require("clock_info").loadCount) { // don't load if a clock_info was already loaded | ||
// Load the clock infos | ||
let clockInfoItems = require("clock_info").load(); | ||
// Add the | ||
let clockInfoMenu = require("clock_info").addInteractive(clockInfoItems, { | ||
app : "widclkinfo", | ||
let clockInfoItems = clock_info.load(); | ||
|
||
// TODO only do checks if widget_utils.swipeOn is being used | ||
let wuo = widget_utils.offset; | ||
|
||
let clockInfoMenu = clock_info.addInteractive(clockInfoItems, { | ||
app: "widclkinfo", | ||
// Add the dimensions we're rendering to here - these are used to detect taps on the clock info area | ||
x : 0, y: 0, w: 72, h:24, | ||
x: 0, | ||
y: 0, // maybe set offset to initial offset | ||
w: 72, | ||
h: 24, | ||
// You can add other information here you want to be passed into 'options' in 'draw' | ||
// This function draws the info | ||
draw : (itm, info, options) => { | ||
draw: (itm, info, options) => { | ||
// itm: the item containing name/hasRange/etc | ||
// info: data returned from itm.get() containing text/img/etc | ||
// options: options passed into addInteractive | ||
clockInfoInfo = info; | ||
if (WIDGETS["clkinfo"]) | ||
wuo = 0 | widget_utils.offset; | ||
clockInfoMenu.y = options.y + wuo; | ||
if (WIDGETS["clkinfo"]) { | ||
WIDGETS["clkinfo"].draw(WIDGETS["clkinfo"]); | ||
console.log("Clock Info was updated, thus drawing widget."); | ||
} | ||
} | ||
}); | ||
let clockInfoInfo; // when clockInfoMenu.draw is called we set this up | ||
|
@@ -25,12 +35,12 @@ | |
width: clockInfoMenu.w, | ||
draw:function(e) { | ||
clockInfoMenu.x = e.x; | ||
clockInfoMenu.y = e.y; | ||
wuo = 0 | widget_utils.offset; | ||
clockInfoMenu.y = e.y + wuo; | ||
var o = clockInfoMenu; | ||
// Clear the background | ||
g.reset(); | ||
// indicate focus - make background reddish | ||
//if (clockInfoMenu.focus) g.setBgColor(g.blendColor(g.theme.bg, "#f00", 0.25)); | ||
// indicate focus | ||
if (clockInfoMenu.focus) g.setColor("#f00"); | ||
g.clearRect(o.x, o.y, o.x+o.w-1, o.y+o.h-1); | ||
if (clockInfoInfo) { | ||
|
@@ -47,4 +57,20 @@ | |
} | ||
} | ||
}; | ||
} | ||
|
||
Bangle.on("hidden", () => { | ||
console.log("hidden"); | ||
clockInfoMenu.y = -24; | ||
if (clockInfoMenu.focus) { | ||
clockInfoMenu.force_blur(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because we've checked There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see your problem - I think that's ok to have the internal focus and the exposed one, we could rename the internal one so we present an API that doesn't give away internal details if you like? |
||
console.log("Forced blur bc hidden"); | ||
} | ||
}); | ||
|
||
Bangle.on("shown", () => { | ||
clockInfoMenu.y = 0; | ||
console.log("shown"); | ||
if (WIDGETS["clkinfo"]) { | ||
WIDGETS["clkinfo"].draw(WIDGETS["clkinfo"]); | ||
} | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.