aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-02-27 18:53:17 -0500
committerSam Anthony <sam@samanthony.xyz>2024-02-27 18:53:17 -0500
commit257f254bd9d15c74ac50934ca1a8ddeb73e1b617 (patch)
treec168af95b9ca7fe2781b8181d3c6d7366f54c992 /main.go
parent530c7461647152753bbf34bca4e79678cfa6ccb2 (diff)
downloadvolute-257f254bd9d15c74ac50934ca1a8ddeb73e1b617.zip
allow widgets to lock focus on themselves
Diffstat (limited to 'main.go')
-rw-r--r--main.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/main.go b/main.go
index 656f749..c92c680 100644
--- a/main.go
+++ b/main.go
@@ -28,7 +28,7 @@ func run() {
wg := new(sync.WaitGroup)
defer wg.Wait()
- focus := widget.NewFocus([]int{1, POINTS, POINTS, POINTS, POINTS})
+ focus := widget.NewFocusMaster([]int{1, POINTS, POINTS, POINTS, POINTS})
defer focus.Close()
displacementChan := make(chan uint)
@@ -87,7 +87,7 @@ func run() {
eventLoop(env, &focus)
}
-func eventLoop(env gui.Env, focus *widget.Focus) {
+func eventLoop(env gui.Env, focus *widget.FocusMaster) {
for event := range env.Events() {
switch event := event.(type) {
case win.WiClose:
@@ -97,13 +97,13 @@ func eventLoop(env gui.Env, focus *widget.Focus) {
case 'q':
return
case 'h':
- focus.Left()
+ focus.TryLeft()
case 'j':
- focus.Down()
+ focus.TryDown()
case 'k':
- focus.Up()
+ focus.TryUp()
case 'l':
- focus.Right()
+ focus.TryRight()
}
}
}