1

我想将一些文本MultiLineEntry作为按钮事件附加到此。我知道如何设置文本,但找不到任何附加文本的示例。有没有其他widget可用于此目的?到目前为止,这是我的代码:

package main

import (
    "fmt"
    "fyne.io/fyne/app"
    "fyne.io/fyne/container"
    "fyne.io/fyne/widget"
)

func main() {
    a := app.New()
    w := a.NewWindow("Hello")

    largeText := widget.NewMultiLineEntry()
    largeText.SetText("Lorem ipsum ...")
    largeText.SetPlaceHolder("Type here")

    form := &widget.Form{
        Items: []*widget.FormItem{
        },
        OnCancel: func() {
            fmt.Println("Cancelled")
        },
        OnSubmit: func() {
            fmt.Println("Form submitted")
            // EVENT TO APPEND TO MULTILINE
        },
    }

    w.SetContent(container.NewVBox(form,largeText))

    w.ShowAndRun()
}
4

1 回答 1

2

您可以先获取然后设置:

    largeText := widget.NewMultiLineEntry()
    largeText.SetText("Lorem ipsum ...")
    originalText := largeText.Text
    fmt.Println(originalText)
    newText := originalText + "appending new text"
    largeText.SetText(newText)
于 2020-12-13T15:01:51.240 回答