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

Under v2.6.0-alpha1, whien compiling with the --tags mobile flag, it always complains about needing fyne.Do(...) wrappers for stuff in the main thread #5535

Open
2 tasks done
pneumaticdeath opened this issue Feb 15, 2025 · 2 comments
Labels
unverified A bug that has been reported but not verified

Comments

@pneumaticdeath
Copy link

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

When I compile the code below using fyne build --tags mobile it complains about window.ShowAndRun() not being called with a fyne.Do(..) wrapper, even though it's being called from the main thread.

How to reproduce

  1. Compile the code below using fyne.io/fyne/[email protected] and the --tags mobile flag
  2. run the resulting binary
  3. Note complaints...

Screenshots

titania:dragtest mitch$ fyne build --tags mobile
titania:dragtest mitch$ ./io.patenaude.dragtesst
2025/02/15 15:27:31 *** Error in Fyne call thread, this should have been called in fyne.Do[AndWait] ***
2025/02/15 15:27:31   From: /Users/mitch/go/src/dragtest/dragtest.go:61
2025/02/15 15:27:31 *** Error in Fyne call thread, this should have been called in fyne.Do[AndWait] ***
2025/02/15 15:27:31   From: /Users/mitch/go/src/dragtest/dragtest.go:63
2025/02/15 15:27:31 *** Error in Fyne call thread, this should have been called in fyne.Do[AndWait] ***
2025/02/15 15:27:31   From: /Users/mitch/go/src/dragtest/dragtest.go:63
2025/02/15 15:27:31 *** Error in Fyne call thread, this should have been called in fyne.Do[AndWait] ***
2025/02/15 15:27:31   From: /Users/mitch/go/src/dragtest/dragtest.go:63

Example code

package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
)

var _ fyne.Draggable = (*MyWidget)(nil)
var _ fyne.Tappable = (*MyWidget)(nil)

type MyWidget struct {
	widget.BaseWidget

	label *canvas.Text
}

func NewWidget(text string) *MyWidget {
	w := &MyWidget{}

	w.label = canvas.NewText(text, theme.TextColor())
	w.label.TextSize = 20.0

	w.ExtendBaseWidget(w)
	return w
}

func (w *MyWidget) CreateRenderer() fyne.WidgetRenderer {
	return widget.NewSimpleRenderer(w.label)
}

func (w *MyWidget) Dragged(e *fyne.DragEvent) {
	fmt.Println("DragEvent ", e)
	curPos := w.Position()
	dx, dy := e.Dragged.Components()
	w.Move(fyne.NewPos(curPos.X + dx, curPos.Y + dy))
}

func (w *MyWidget) DragEnd() {
	fmt.Println("DragEnd")
}

func (w *MyWidget) Tapped(e *fyne.PointEvent) {
	w.label.TextStyle.Bold = !w.label.TextStyle.Bold
	fmt.Println("Tap")
}

func main() {
	a := app.New()
	w := a.NewWindow("Drag Test")

	myWidget := NewWidget("Foo")

	cont := container.NewCenter(myWidget)

	w.SetContent(cont)
	w.Resize(fyne.NewSize(800,600))
	w.ShowAndRun()
}

Fyne version

v2.6.0-alpha1

Go compiler version

v1.23.4

Operating system and version

MacOS sonoma 14.6.1

Additional Information

The code appears to work fine, it just complains about everything

@pneumaticdeath pneumaticdeath added the unverified A bug that has been reported but not verified label Feb 15, 2025
@andydotxyz
Copy link
Member

I cannot replicate here on macOS Sonoma.

Was this an M1/2/3 computer or Intel?

@pneumaticdeath
Copy link
Author

This is on a M2 macbook air. I don't know what else might be different.

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