core
core copied to clipboard
Text field in form not saving before opening dialog
Describe the bug
If you type something in a text field in a form and then open a dialog without first exiting the text field, it will not apply the text of the text field to the struct in time for the dialog to get it. I noticed this while responding to #1108.
How to reproduce
Run the code below, type something in the text field, and then press the sign in button without first exiting the text field.
Example code
type user struct {
Username string
}
func main() {
b := core.NewBody()
u := &user{}
core.NewForm(b).SetStruct(u)
bt := core.NewButton(b).SetText("Sign in")
bt.OnClick(func(e events.Event) {
makeHome(bt, u)
})
b.RunMainWindow()
}
func makeHome(ctx core.Widget, u *user) {
home := core.NewBody().AddTitle("Hello, " + u.Username)
core.NewText(home).SetText("Page content")
home.RunFullDialog(ctx)
}
Relevant output
No response
Platform
macOS