-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
[Feature Request] Global key press event #501
Labels
enhancement
New feature or request
Comments
Thats only my suppose: KeyAny = KayA| KeyB | KeyC // etc |
gucio321
added a commit
to gucio321/giu
that referenced
this issue
May 7, 2022
should be helpful in AllenDang#501
@gucio321 Thanks. it still need some "adjustment", but works now. package main
import (
"fmt"
"strings"
g "github.com/AllenDang/giu"
)
var input string
var focused bool
var should_focus bool
func loop() {
g.SingleWindow().Layout(
g.Custom(func() {
if should_focus {
should_focus = true
focused = true
g.SetKeyboardFocusHere()
}
g.InputText(&input).Build()
}),
)
}
func main() {
wnd := g.NewMasterWindow("", 400, 300, 0)
wnd.SetAdditionalInputHandlerCallback(func(key g.Key, mod g.Modifier, act g.Action) {
if !focused && act == g.Press {
input += strings.ToLower(string([]byte{byte(key)}))
should_focus = true
}
fmt.Println(key, mod, act)
})
wnd.Run(loop)
} |
@aj3423 I did an example for that issue here: https://github.com/AllenDang/giu/blob/9e3f60abdd963f8e7da62133b2d9a2b3c1459356/examples/issue-501/main.go it should be what you're looking for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Related problem
I'm writing a debugger, there is an
giu.InputText
for typing commands. It isn't always focused because user may click somewhere else, I want to auto-focus the input when user start typing commands, instead of clicking it to gain focus manually.I see
giu.Event().OnKeyPressed()
andgiu.IsKeyPressed()
, they both require a specific key code. Possible to monitor key event globally?Your request
.
Alternative solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: