Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A dialog with a table. Selecting a cell and closing the dialog produces a Fyne error #5166

Open
2 tasks done
ErikKalkoken opened this issue Sep 27, 2024 · 1 comment
Open
2 tasks done
Labels
unverified A bug that has been reported but not verified

Comments

@ErikKalkoken
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

We have a custom dialog with a table widget inside. When a cell is selected, the dialog is closed. This works, but also logs the following error is logged:

2024/09/27 18:19:24 Fyne error:  Failed to focus object which is not part of the canvas’ content, menu or overlays.
2024/09/27 18:19:24   At: /home/erik/go/pkg/mod/fyne.io/fyne/[email protected]/internal/driver/common/canvas.go:182

The same approach , but with a list widget works flawlessly.

To demonstrate this I have included two almost identical dialog implementations in the example code. One with a table (which produced the error) and one with a list (which does not produce any error).

How to reproduce

  1. Open the dialog
  2. Click on a cell in the table
  3. Error appears

Screenshots

No response

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/dialog"
	"fyne.io/fyne/v2/widget"
)

var data = [][]string{
	{"top left", "top right"},
	{"bottom left", "bottom right"},
}

func main() {
	a := app.New()
	w := a.NewWindow("Table Widget")

	b1 := widget.NewButton("Show Table", func() {
		t := widget.NewTable(
			func() (int, int) {
				return len(data), len(data[0])
			},
			func() fyne.CanvasObject {
				return widget.NewLabel("template")
			},
			func(id widget.TableCellID, co fyne.CanvasObject) {
				co.(*widget.Label).SetText(data[id.Row][id.Col])
			})

		d := dialog.NewCustom("Dialog", "Close", t, w)
		d.Show()
		d.Resize(fyne.Size{Width: 600, Height: 400})
		t.OnSelected = func(_ widget.TableCellID) {
			d.Hide()
		}
	})

	b2 := widget.NewButton("Show List", func() {
		l := widget.NewList(
			func() int {
				return len(data)
			},
			func() fyne.CanvasObject {
				return widget.NewLabel("template")
			},
			func(id widget.ListItemID, co fyne.CanvasObject) {
				co.(*widget.Label).SetText(data[id][0])
			})

		d := dialog.NewCustom("Dialog", "Close", l, w)
		d.Show()
		d.Resize(fyne.Size{Width: 600, Height: 400})
		l.OnSelected = func(_ widget.ListItemID) {
			d.Hide()
		}
	})

	w.SetContent(container.NewCenter(container.NewHBox(b1, b2)))
	w.Resize(fyne.Size{Width: 800, Height: 600})
	w.ShowAndRun()
}

Fyne version

2.5.1

Go compiler version

1.23.1

Operating system and version

Ubuntu 22.04.4 LTS

Additional Information

This error is reproducible.

@ErikKalkoken ErikKalkoken added the unverified A bug that has been reported but not verified label Sep 27, 2024
@andydotxyz
Copy link
Member

Just out of interest if you put a short (100ms) delay before the Hide does the warning disappear?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unverified A bug that has been reported but not verified
Projects
None yet
Development

No branches or pull requests

2 participants