giu icon indicating copy to clipboard operation
giu copied to clipboard

[howTo] Respond to enter key in an input box

Open schabil opened this issue 3 years ago • 1 comments

What happend?

Hey,

thanks a lot for your great work.

I am currently trying to respond to the "Enter" key in an input box. However, the combination of if g.IsKeyPressed(g.KeyEnter) && g.IsItemActive() does not work.

Enter makes the focus disappear from the item (which is ok) but at that moment the IF condition no longer applies. If I omit isItemActive all enter keys are taken into account, which I don't want.

Code example

main.go

g.InputText(&doc_tags_test).AutoComplete(liste_tags), g.Custom(func() { if g.IsKeyPressed(g.KeyEnter) && g.IsItemActive() { fmt.Println("Enter") } }),

To Reproduce

  1. Run my demo

Version

v0.6.1

OS

Linux Manjaro

schabil avatar Feb 16 '22 00:02 schabil

~~@schabil I'd suggest you to try with (*InputTextMultilineWidget).Callback(...)~~ well it doesn't work btw @AllenDang IMO imgui.InputTextCallbackData needs some API in giu

gucio321 avatar Feb 16 '22 08:02 gucio321

it was resolved in #660

gucio321 avatar May 08 '23 13:05 gucio321