Skip to content

Question about architecture #4793

Closed Answered by andydotxyz
chicogamedev asked this question in Q&A
Discussion options

You must be logged in to vote

This really is more of a Go question than a Fyne architecture question.
We don't have extra parameters to pass into button callbacks because it would cause all callbacks to need to mirror this and it's hard to know if you'd want the button or window etc etc.

However there are many ways to work with this, you could use a wrapper function:

func NewContent() *fyne.Container {
	a := app.New()
	mainWindow := a.NewWindow("Thing")
	btTest := widget.NewButton("Test", func() {
		btTestClicked(mainWindow)
	})

	content := container.NewStack(btTest)
	return content
}

func btTestClicked(win fyne.Window) {
	win.SetContent(SomeOtherContent)
}

Or attach your functionality to a custom type:

type myApp s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@chicogamedev
Comment options

Answer selected by chicogamedev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants