Skip to content

Commit

Permalink
widget: don't let unfocused Clickables swallow key presses
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Naur <[email protected]>
  • Loading branch information
eliasnaur committed Jul 25, 2022
1 parent b67bef3 commit 26e7101
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion widget/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ func (b *Clickable) Layout(gtx layout.Context, w layout.Widget) layout.Dimension
semantic.DisabledOp(disabled).Add(gtx.Ops)
b.click.Add(gtx.Ops)
if !disabled {
key.InputOp{Tag: &b.keyTag, Keys: "⏎|Space"}.Add(gtx.Ops)
keys := key.Set("⏎|Space")
if !b.focused {
keys = ""
}
key.InputOp{Tag: &b.keyTag, Keys: keys}.Add(gtx.Ops)
} else {
b.focused = false
}
Expand Down

0 comments on commit 26e7101

Please sign in to comment.