Skip to content

Commit

Permalink
unfocus grid view items when tapping between them
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Feb 18, 2024
1 parent c6687aa commit 8d038ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ui/widgets/gridview.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ func (g *GridView) Resize(size fyne.Size) {
g.BaseWidget.Resize(size)
}

var _ fyne.Tappable = (*GridView)(nil)

func (g *GridView) Tapped(*fyne.PointEvent) {
fyne.CurrentApp().Driver().CanvasForObject(g).Unfocus()
}

func (g *GridView) numCols() int {
if g.numColsCached == -1 {
// logic here taken from gridwrap.go in Fyne codebase
Expand Down
6 changes: 6 additions & 0 deletions ui/widgets/gridviewitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ func (g *GridViewItem) TypedRune(rune) {
// intentionally blank
}

var _ fyne.Tappable = (*GridViewItem)(nil)

func (g *GridViewItem) Tapped(*fyne.PointEvent) {
fyne.CurrentApp().Driver().CanvasForObject(g).Unfocus()
}

func (g *GridViewItem) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(g.container)
}
Expand Down

0 comments on commit 8d038ce

Please sign in to comment.