From 9f638228069b4c0649630de80c10f887406b88b5 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sun, 5 Nov 2023 12:10:15 -0800 Subject: [PATCH] allow Esc key to clear and unfocus search fields --- ui/widgets/searchentry.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/widgets/searchentry.go b/ui/widgets/searchentry.go index c26786b..41d932e 100644 --- a/ui/widgets/searchentry.go +++ b/ui/widgets/searchentry.go @@ -37,6 +37,15 @@ func NewSearchEntry() *SearchEntry { return sf } +func (s *SearchEntry) TypedKey(e *fyne.KeyEvent) { + if e.Name == fyne.KeyEscape { + s.SetText("") + fyne.CurrentApp().Driver().CanvasForObject(s).Unfocus() + return + } + s.Entry.TypedKey(e) +} + func (s *SearchEntry) Refresh() { s.updateActionButton() s.Entry.Refresh()