🐛 Handle key events globally

This commit is contained in:
Andreas Schneider 2021-03-06 14:16:59 +01:00
parent c776ed21bd
commit 247c750932
1 changed files with 6 additions and 2 deletions

View File

@ -95,10 +95,10 @@ func main() {
return len(currentEntries) return len(currentEntries)
}, },
func() fyne.CanvasObject { func() fyne.CanvasObject {
tn := canvas.NewText("Dummy", theme.TextColor()) tn := canvas.NewText("Dummy", theme.ForegroundColor())
tn.TextStyle.Bold = true tn.TextStyle.Bold = true
td := canvas.NewText("Dummy", theme.TextColor()) td := canvas.NewText("Dummy", theme.ForegroundColor())
td.TextSize = theme.TextSize() * 8 / 10 td.TextSize = theme.TextSize() * 8 / 10
return container.NewHBox( return container.NewHBox(
@ -124,6 +124,7 @@ func main() {
l.OnSelected = func(id widget.ListItemID) { l.OnSelected = func(id widget.ListItemID) {
currentId = id currentId = id
w.Canvas().Focus(e)
} }
e.OnChanged = func(s string) { e.OnChanged = func(s string) {
@ -184,6 +185,9 @@ func main() {
} }
return false return false
} }
w.Canvas().SetOnTypedKey(func(event *fyne.KeyEvent) {
e.onKeyTyped(event)
})
w.Canvas().Focus(e) w.Canvas().Focus(e)