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

[bug] InputText widget with auto-completion and on change callback, does not callback when auto-completed. #583

Closed
frenkoes opened this issue Nov 16, 2022 · 2 comments · Fixed by #681
Assignees
Labels
bug Something isn't working

Comments

@frenkoes
Copy link

What happend?

When using InputText widget with auto completion and an OnChange() callback. The OnChange callback won't be called when the InputText is auto-completed.

Code example

main.go
package main

import (
	"fmt"

	g "github.com/AllenDang/giu"
)

var input string

func main() {
	mw := g.NewMasterWindow("Test", 500, 500, 0)

	mw.Run(loop)
}

func loop() {
	strList := []string{"Hello", "Hallo", "Halo"}
	g.InputText(&input).OnChange(myCb).AutoComplete(strList).Build()
}

func myCb() {
	fmt.Println("My inputtext string:", input)
}

To Reproduce

  1. Run my demo
  2. Type in a 'H'
  3. See the callback get called
  4. Auto complete it
  5. See the callback not being called.

Version

master

OS

Ubuntu

@frenkoes frenkoes added the bug Something isn't working label Nov 16, 2022
@frenkoes
Copy link
Author

frenkoes commented Nov 17, 2022

In TextWidgets.go (228-278) the callback is called when a change is made. And after this the auto-completion part start doing its thing. I think by adding a call to the callback where the string is auto-completed will solve it, if this is actually a bug. Something like this:

		// Press enter will replace value string with first match candidate
		if IsKeyPressed(KeyEnter) {
			*i.value = state.autoCompleteCandidates[0].Str
			if i.onChange != nil {
				i.onChange()
			}
			state.autoCompleteCandidates = nil
		}

@gucio321 gucio321 self-assigned this Jul 13, 2023
gucio321 added a commit to gucio321/giu that referenced this issue Jul 13, 2023
@gucio321
Copy link
Collaborator

I'm sorry, I had to miss this somehow - fix comming soon 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants