io/input,widget: [API] replace per-widget Focused with Source.Focused

Widgets have themselves as tags, by convention, and so it's possible to
replace the per-widget Focused methods with a general-purpose Source.
Focused query.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-28 10:35:51 -06:00
parent c3f2abebca
commit e59f91dfd0
9 changed files with 65 additions and 68 deletions
+4 -4
View File
@@ -39,10 +39,10 @@ func TestClickable(t *testing.T) {
}
gtx.Execute(key.FocusCmd{Tag: &b1})
frame()
if !b1.Focused() {
if !gtx.Focused(&b1) {
t.Error("button 1 did not gain focus")
}
if b2.Focused() {
if gtx.Focused(&b2) {
t.Error("button 2 should not have focus")
}
r.Queue(
@@ -73,10 +73,10 @@ func TestClickable(t *testing.T) {
frame()
gtx.Execute(key.FocusCmd{Tag: &b2})
frame()
if b1.Focused() {
if gtx.Focused(&b1) {
t.Error("button 1 should not have focus")
}
if !b2.Focused() {
if !gtx.Focused(&b2) {
t.Error("button 2 did not gain focus")
}
r.Queue(