-
-
Notifications
You must be signed in to change notification settings - Fork 93
Closed
Labels
bugSomething isn't working correctlySomething isn't working correctlyconfirmedThis bug has been confirmedThis bug has been confirmed
Milestone
Description
Describe the bug
The new page switching is really nice, unfortunately it doesn't seem to play completely nicely with focus. This may also be user error.
How to reproduce
I ran this two ways to try and understand what was going on, first:
- Run example code (slightly modified from tutorial)
- Observe that the text box is focused as expected and styled to indicate that
- Enter a string and click sign in button
- Observe that the text box on the "home" page is not styled as focused
- Attempt to type some characters slowly one at a time
- Observe that the text box isn't actually focused for the first few key presses
- Click sign out button
- Observe that the text box is not styled as focused this time
- Attempt to type some characters slowly one at a time
- Observe that the text box isn't actually focused for the first few key presses
Second, swap to using SetFocusEvent instead by switching which lines are commented and then:
- Run example code
- Observe that the text box is not styled as focused
- Attempt to enter some characters
- Observe that text box is actually focused
- Click sign in button
- Observe that text box on "home" page is not styled as focused
- Attempt to type some characters
- Observe that the text box is actually focused
- Click sign out button
- Attempt to enter text once again, observing that once again the text box is actually focused but not styled as such
Example code
package main
import (
"cogentcore.org/core/core"
"cogentcore.org/core/events"
)
type user struct {
Username string
}
func main() {
b := core.NewBody()
u := &user{}
pg := core.NewPages(b)
pg.AddPage("sign-in", func(pg *core.Pages) {
userField := core.NewTextField(pg)
userField.StartFocus()
//userField.SetFocusEvent()
core.NewButton(pg).SetText("Sign in").OnClick(func(e events.Event) {
u.Username = userField.Text()
pg.Open("home")
})
})
pg.AddPage("home", func(pg *core.Pages) {
core.NewText(pg).SetText("Welcome, " + u.Username + "!").SetType(core.TextHeadlineSmall)
newField := core.NewTextField(pg)
newField.StartFocus()
//newField.SetFocusEvent()
core.NewButton(pg).SetText("Sign out").OnClick(func(e events.Event) {
*u = user{}
pg.Open("sign-in")
})
})
b.RunMainWindow()
}Relevant output
No response
Platform
Linux
Metadata
Metadata
Assignees
Labels
bugSomething isn't working correctlySomething isn't working correctlyconfirmedThis bug has been confirmedThis bug has been confirmed
Type
Projects
Status
Done