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

TextEditor: How to get a TextEditor's content ? #21

Closed
zrcoder opened this issue Jun 26, 2024 · 2 comments
Closed

TextEditor: How to get a TextEditor's content ? #21

zrcoder opened this issue Jun 26, 2024 · 2 comments

Comments

@zrcoder
Copy link

zrcoder commented Jun 26, 2024

It always be empty when I print the content of the TextEditor, test code is below:

package main

import (
	"fmt"

	"github.com/roblillack/spot"
	"github.com/roblillack/spot/ui"
)

func main() {
	ui.Init()

	spot.MountFn(func(ctx *spot.RenderContext) spot.Component {
		content, setContent := spot.UseState(ctx, "")

		return &ui.Window{
			Title: "Test",
			Width: 800, Height: 600,
			Children: []spot.Component{
				&ui.Button{
					X: 10, Y: 10, Width: 780, Height: 20,
					Title: "OK",
					OnClick: func() {
						fmt.Println("content of the textEditor is:", content) // content is always empty here
					},
				},
				&ui.TextEditor{
					X: 10, Y: 30, Width: 780, Height: 560,
					Text:     content,
					OnChange: setContent,
				},
			},
		}
	})

	ui.Run()
}
@roblillack
Copy link
Owner

Hi @zrcoder, you seem to be using Cocoa. This was a bug, which was just fixed with a contribution by @Suremeo in #20. What coincidence!

If you try again with the main branch, things should be working now. Can you confirm?

@zrcoder
Copy link
Author

zrcoder commented Jun 27, 2024

Hi @zrcoder, you seem to be using Cocoa. This was a bug, which was just fixed with a contribution by @Suremeo in #20. What coincidence!

If you try again with the main branch, things should be working now. Can you confirm?

Yes, I used spot on my mac, and the code works with the main branch. Thanks a lot, spot is very good, easy enouph to use.

@zrcoder zrcoder closed this as completed Jun 27, 2024
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