andlabs / ui

Platform-native GUI library for Go.
Other
8.34k stars 647 forks source link

textfield .RequestFocus() #361

Open andrewarrow opened 5 years ago

andrewarrow commented 5 years ago

Hello, I've been using https://github.com/dontpanic92/wxGo for a while but moving to this system and it's great! The one thing I'm missing is making a textfield have the blinking cursor with a request focus call. I was thinking about using:

https://github.com/go-vgo/robotgo

To simulate a mouse click inside the textfield. Is this a bad idea?

andrewarrow commented 5 years ago

oh, I see. If I do:

    mainwin.Destroy()
    mainwin = ui.NewWindow("Testing", 800, 480, true)
    mainwin.SetChild(child)
    mainwin.Show()

My textfield has focus!

andlabs commented 5 years ago

This is the wrong solution. There should be a SetFocus function at some point (not yet), though I don't know why the field isn't getting focus by default if you are creating it before the window is first shown.

andrewarrow commented 5 years ago

I make a window, place a button there to say "start". Then the event for that button clears the screen and adds a textfield. But the textfield has no focus when I do it that way. Only when I remove the mainwindow on start button click. (Or have a textfield on that first screen with the start button)

andlabs commented 5 years ago

Yeah, so I'll need to add a SetFocus function, which isn't even in libui yet.