Skip to content

Commit

Permalink
Only focus collections on desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Oct 3, 2023
1 parent 6822d1a commit 674f8cb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
13 changes: 8 additions & 5 deletions widget/gridwrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,16 @@ func (l *gridWrapLayout) setupGridItem(li *gridWrapItem, id GridWrapItemID, focu
f(id, li.child)
}
li.onTapped = func() {
l.list.RefreshItem(l.list.currentFocus)
canvas := fyne.CurrentApp().Driver().CanvasForObject(l.list)
if canvas != nil {
canvas.Focus(l.list)
if !fyne.CurrentDevice().IsMobile() {
l.list.RefreshItem(l.list.currentFocus)
canvas := fyne.CurrentApp().Driver().CanvasForObject(l.list)
if canvas != nil {
canvas.Focus(l.list)
}

l.list.currentFocus = id
}

l.list.currentFocus = id
l.list.Select(id)
}
}
Expand Down
11 changes: 7 additions & 4 deletions widget/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,15 @@ func (l *listLayout) setupListItem(li *listItem, id ListItemID, focus bool) {
f(id, li.child)
}
li.onTapped = func() {
canvas := fyne.CurrentApp().Driver().CanvasForObject(l.list)
if canvas != nil {
canvas.Focus(l.list)
if !fyne.CurrentDevice().IsMobile() {
canvas := fyne.CurrentApp().Driver().CanvasForObject(l.list)
if canvas != nil {
canvas.Focus(l.list)
}

l.list.currentFocus = id
}

l.list.currentFocus = id
l.list.Select(id)
}
}
Expand Down
14 changes: 8 additions & 6 deletions widget/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,15 @@ func (t *Table) Tapped(e *fyne.PointEvent) {
}
t.Select(TableCellID{row, col})

t.RefreshItem(t.currentFocus)
canvas := fyne.CurrentApp().Driver().CanvasForObject(t)
if canvas != nil {
canvas.Focus(t)
if !fyne.CurrentDevice().IsMobile() {
t.RefreshItem(t.currentFocus)
canvas := fyne.CurrentApp().Driver().CanvasForObject(t)
if canvas != nil {
canvas.Focus(t)
}
t.currentFocus = TableCellID{row, col}
t.RefreshItem(t.currentFocus)
}
t.currentFocus = TableCellID{row, col}
t.RefreshItem(t.currentFocus)
}

// columnAt returns a positive integer (or 0) for the column that is found at the `pos` X position.
Expand Down
12 changes: 7 additions & 5 deletions widget/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,14 @@ func (n *treeNode) Tapped(*fyne.PointEvent) {
}

n.tree.Select(n.uid)
canvas := fyne.CurrentApp().Driver().CanvasForObject(n.tree)
if canvas != nil {
canvas.Focus(n.tree)
if !fyne.CurrentDevice().IsMobile() {
canvas := fyne.CurrentApp().Driver().CanvasForObject(n.tree)
if canvas != nil {
canvas.Focus(n.tree)
}
n.tree.currentFocus = n.uid
n.Refresh()
}
n.tree.currentFocus = n.uid
n.Refresh()
}

func (n *treeNode) partialRefresh() {
Expand Down

0 comments on commit 674f8cb

Please sign in to comment.