defensive nil checks around CanvasForObject
This commit is contained in:
@@ -152,7 +152,7 @@ func (b *BrowsingPane) doSetPage(p Page) bool {
|
|||||||
}
|
}
|
||||||
// TODO: reset focus only if something inside the previous page had focus
|
// TODO: reset focus only if something inside the previous page had focus
|
||||||
if c := fyne.CurrentApp().Driver().CanvasForObject(b); c != nil {
|
if c := fyne.CurrentApp().Driver().CanvasForObject(b); c != nil {
|
||||||
c.Focus(nil)
|
c.Unfocus()
|
||||||
}
|
}
|
||||||
b.curPage = p
|
b.curPage = p
|
||||||
if np, ok := p.(CanShowNowPlaying); ok {
|
if np, ok := p.(CanShowNowPlaying); ok {
|
||||||
|
|||||||
@@ -392,7 +392,9 @@ func NewPlaylistPageHeader(page *PlaylistPage) *PlaylistPageHeader {
|
|||||||
}
|
}
|
||||||
buttonRow.Objects[3] = searchEntry
|
buttonRow.Objects[3] = searchEntry
|
||||||
searchEntry.SetMinWidth(minW)
|
searchEntry.SetMinWidth(minW)
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(a).Focus(searchEntry)
|
if c := fyne.CurrentApp().Driver().CanvasForObject(a); c != nil {
|
||||||
|
c.Focus(searchEntry)
|
||||||
|
}
|
||||||
fyne.NewAnimation(myTheme.AnimationDurationShort, func(f float32) {
|
fyne.NewAnimation(myTheme.AnimationDurationShort, func(f float32) {
|
||||||
w := (200-minW)*f + minW
|
w := (200-minW)*f + minW
|
||||||
searchEntry.SetMinWidth(w)
|
searchEntry.SetMinWidth(w)
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ func NewVolumeSlider(width float32) *volumeSlider {
|
|||||||
|
|
||||||
func (v *volumeSlider) Tapped(e *fyne.PointEvent) {
|
func (v *volumeSlider) Tapped(e *fyne.PointEvent) {
|
||||||
v.Slider.Tapped(e)
|
v.Slider.Tapped(e)
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(v).Unfocus()
|
if c := fyne.CurrentApp().Driver().CanvasForObject(v); c != nil {
|
||||||
|
c.Unfocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *volumeSlider) MinSize() fyne.Size {
|
func (v *volumeSlider) MinSize() fyne.Size {
|
||||||
|
|||||||
@@ -67,7 +67,9 @@ func (g *FocusList) FocusNeighbor(curItem widget.ListItemID, up bool) {
|
|||||||
other := g.ItemForID(focusIdx)
|
other := g.ItemForID(focusIdx)
|
||||||
g.mutex.Unlock()
|
g.mutex.Unlock()
|
||||||
if other != nil {
|
if other != nil {
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(other.(fyne.Focusable))
|
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
|
||||||
|
c.Focus(other.(fyne.Focusable))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,8 +122,7 @@ func (l *FocusListRowBase) SetItemID(id widget.ListItemID) {
|
|||||||
|
|
||||||
func (l *FocusListRowBase) EnsureUnfocused() {
|
func (l *FocusListRowBase) EnsureUnfocused() {
|
||||||
if l.Focused {
|
if l.Focused {
|
||||||
c := fyne.CurrentApp().Driver().CanvasForObject(l)
|
if c := fyne.CurrentApp().Driver().CanvasForObject(l); c != nil {
|
||||||
if c != nil {
|
|
||||||
c.Unfocus()
|
c.Unfocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -286,7 +286,9 @@ func (g *GridView) Resize(size fyne.Size) {
|
|||||||
var _ fyne.Tappable = (*GridView)(nil)
|
var _ fyne.Tappable = (*GridView)(nil)
|
||||||
|
|
||||||
func (g *GridView) Tapped(*fyne.PointEvent) {
|
func (g *GridView) Tapped(*fyne.PointEvent) {
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(g).Unfocus()
|
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
|
||||||
|
c.Unfocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GridView) createGridWrap() {
|
func (g *GridView) createGridWrap() {
|
||||||
@@ -343,7 +345,9 @@ func (g *GridView) createNewItemCard() fyne.CanvasObject {
|
|||||||
g.grid.ScrollTo(focusIndex)
|
g.grid.ScrollTo(focusIndex)
|
||||||
g.stateMutex.RLock()
|
g.stateMutex.RLock()
|
||||||
if item, ok := g.itemForIndex[focusIndex]; ok {
|
if item, ok := g.itemForIndex[focusIndex]; ok {
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(item)
|
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
|
||||||
|
c.Focus(item)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
g.stateMutex.RUnlock()
|
g.stateMutex.RUnlock()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,8 +513,10 @@ func (g *GridViewItem) Update(model *GridViewItemModel) {
|
|||||||
g.secondaryText.Refresh()
|
g.secondaryText.Refresh()
|
||||||
g.Cover.ResetPlayButton()
|
g.Cover.ResetPlayButton()
|
||||||
if g.focused {
|
if g.focused {
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(g).Focus(nil)
|
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
|
||||||
g.FocusLost()
|
c.Unfocus()
|
||||||
|
g.FocusLost()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,7 +591,9 @@ func (g *GridViewItem) TypedRune(rune) {
|
|||||||
var _ fyne.Tappable = (*GridViewItem)(nil)
|
var _ fyne.Tappable = (*GridViewItem)(nil)
|
||||||
|
|
||||||
func (g *GridViewItem) Tapped(*fyne.PointEvent) {
|
func (g *GridViewItem) Tapped(*fyne.PointEvent) {
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(g).Unfocus()
|
if c := fyne.CurrentApp().Driver().CanvasForObject(g); c != nil {
|
||||||
|
c.Unfocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GridViewItem) CreateRenderer() fyne.WidgetRenderer {
|
func (g *GridViewItem) CreateRenderer() fyne.WidgetRenderer {
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ func (t *TrackPosSlider) Tapped(e *fyne.PointEvent) {
|
|||||||
t.Slider.Tapped(e)
|
t.Slider.Tapped(e)
|
||||||
|
|
||||||
// don't keep focus after being tapped
|
// don't keep focus after being tapped
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(t).Focus(nil)
|
if c := fyne.CurrentApp().Driver().CanvasForObject(t); c != nil {
|
||||||
|
c.Unfocus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// override to increase the distance moved by keyboard control
|
// override to increase the distance moved by keyboard control
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ func (sf *SearchEntry) Init() {
|
|||||||
func (s *SearchEntry) TypedKey(e *fyne.KeyEvent) {
|
func (s *SearchEntry) TypedKey(e *fyne.KeyEvent) {
|
||||||
if e.Name == fyne.KeyEscape {
|
if e.Name == fyne.KeyEscape {
|
||||||
s.SetText("")
|
s.SetText("")
|
||||||
fyne.CurrentApp().Driver().CanvasForObject(s).Unfocus()
|
if c := fyne.CurrentApp().Driver().CanvasForObject(s); c != nil {
|
||||||
|
c.Unfocus()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.Entry.TypedKey(e)
|
s.Entry.TypedKey(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user