I'm trying to build a simple code editor with fyne, and I saw in the doc the widget TextGrid, so I tried to use it, but when I run the code I can't modify the text.
here is the code
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/widget"
)
func main() {
a := app.New()
w := a.NewWindow("Text Editor")
w.Resize(fyne.NewSize(1400, 1000))
text := widget.NewTextGrid()
w.SetContent(text)
w.ShowAndRun()
}
if I can't modify it, I don't see the purpose of this widget, is there a way to make it modifiable?
The TextGrid
component is something more developer focused for building more complex components (like a terminal or code editor).
For a ready-to-use text editor use widget.NewMultiLineEditor()
.
You can see a more complete example at https://github.com/FyshOS/textedit/blob/main/ui.go.