ppforge/internal/ui/fieldadd.go

17 lines
453 B
Go
Raw Normal View History

package ui
2022-11-23 20:33:07 +01:00
import (
"fyne.io/fyne/v2/widget"
2023-05-12 09:10:24 +02:00
"gitea.mmo.to/ppForge/ppforge/protocolctl"
2022-11-23 20:33:07 +01:00
)
2023-05-12 17:18:24 +02:00
// GetAdder returns a fyne button which on click creates a new field in the editor
func GetAdder(pEd *ProtocolEditor) *widget.Button {
fieldAdder := widget.NewButton("Add Field", func() {
f := protocolctl.NewEmptyField()
2023-05-12 17:18:24 +02:00
index := protocolctl.AppendField(pEd.Reference, *f)
pEd.AddFieldCreator(CreateFieldEditor(pEd, index, f))
})
2022-11-23 20:33:07 +01:00
return fieldAdder
}