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

Methods for taking/detecting element focus #45

Closed
jonhoo opened this issue Oct 22, 2014 · 2 comments
Closed

Methods for taking/detecting element focus #45

jonhoo opened this issue Oct 22, 2014 · 2 comments

Comments

@jonhoo
Copy link

jonhoo commented Oct 22, 2014

It would be very useful to be able to force focus to specific element (a text field for example), and similarly, to detect when an element gains focus. Something along the lines of:

textfield := ui.NewTextField()
textfield.OnFocus(func() {
    textfield.SetText("")
})
// ...
window.Show()
textfield.Focus()

If we implemented named events, OnFocus could be generalized to something like:

textfield.On(FOCUS, func(e ui.Event) { /* ... */ })

Where FOCUS is an enum of possible event types (well, technically a const of iota, but you get the point). This would also allow a uniform interface to similar operations such as OnChanged (similar to how event handling is done in JavaScript):

textfield.On(FOCUS, func(e ui.Event) { /* ... */ })
textfield.On(CHANGED, func(e ui.Event) { /* ... */ })
textfield.On(KEYDOWN, func(e ui.Event) { /* ... */ })
// etc..
@andlabs
Copy link
Owner

andlabs commented Mar 31, 2018

Partial merge with andlabs/libui#325. There's another issue I want to merge this with as well.

@andlabs
Copy link
Owner

andlabs commented Mar 31, 2018

Partial merge with andlabs/libui#326. This should handle all the needed merges; closing.

@andlabs andlabs closed this as completed Mar 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants