英文:
Does the textgrid widget in go fyne editable?
问题
我正在尝试使用fyne构建一个简单的代码编辑器,并且在文档中看到了TextGrid小部件,所以我尝试使用它,但是当我运行代码时,我无法修改文本。
以下是代码:
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()
}
如果我无法修改它,我看不到这个小部件的目的,有没有办法使其可修改?
英文:
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?
答案1
得分: 1
TextGrid
组件是更面向开发者的,用于构建更复杂的组件(如终端或代码编辑器)的组件。
要使用现成的文本编辑器,请使用widget.NewMultiLineEditor()
。
您可以在https://github.com/fyne-io/examples/blob/develop/textedit/ui.go上查看更完整的示例。
英文:
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/fyne-io/examples/blob/develop/textedit/ui.go.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论