-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathcmd.go
35 lines (30 loc) · 764 Bytes
/
cmd.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/widget"
)
func (w *Window) showNewCmdDialog() {
nameEntry := widget.NewEntry()
textEntry := widget.NewEntry()
textEntry.MultiLine = true
icons := make([]string, len(iconMap))
i := 0
for k, _ := range iconMap {
icons[i] = k
i++
}
iconSelect := widget.NewSelectEntry(icons)
dlg := dialog.NewForm("New Command", "OK", "Cancel", []*widget.FormItem{
widget.NewFormItem("Name", nameEntry),
widget.NewFormItem("Text", textEntry),
widget.NewFormItem("Icon", iconSelect),
}, func(b bool) {
if b {
cmd := &Cmd{Name: nameEntry.Text, Text: textEntry.Text, Icon: iconSelect.Text}
w.AddCmd(cmd)
}
}, w.win)
dlg.Resize(fyne.NewSize(400, 300))
dlg.Show()
}