forked from RickDakan/haunts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_widget.go
36 lines (30 loc) · 958 Bytes
/
save_widget.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
36
package main
import (
"github.com/runningwild/glop/gui"
"github.com/runningwild/glop/gin"
)
type SaveWidget struct {
*gui.VerticalTable
filename *gui.TextEditLine
on_save func(string)
}
func MakeSaveWidget(on_save func(string)) *SaveWidget {
var sw SaveWidget
sw.VerticalTable = gui.MakeVerticalTable()
sw.on_save = on_save
sw.AddChild(gui.MakeTextLine("standard", "Enter Filename", 300, 1, 1, 1, 1))
sw.filename = gui.MakeTextEditLine("standard", "filename", 300, 1, 1, 1, 1)
sw.AddChild(sw.filename)
sw.AddChild(gui.MakeButton("standard", "Save!", 300, 1, 1, 1, 1, func(int64) {
sw.on_save(sw.filename.GetText())
}))
return &sw
}
func (sw *SaveWidget) Respond(ui *gui.Gui, event_group gui.EventGroup) bool {
if found, event := event_group.FindEvent(gin.Return); found && event.Type == gin.Press {
sw.on_save(sw.filename.GetText())
return true
}
sw.VerticalTable.Respond(ui, event_group)
return true
}