文本网格小部件在Go Fyne中是否可编辑?

huangapple go评论76阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2021年11月21日 23:40:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/70056010.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定