2019-06-02 15:40:44 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "log"
|
2021-10-31 20:36:05 -05:00
|
|
|
// import "fmt"
|
2019-06-02 15:40:44 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
2021-10-31 20:36:05 -05:00
|
|
|
// import "github.com/davecgh/go-spew/spew"
|
2019-06-02 15:40:44 -05:00
|
|
|
|
2019-06-02 17:19:53 -05:00
|
|
|
// functions for handling text entry boxes
|
2019-06-02 15:40:44 -05:00
|
|
|
|
2021-10-31 14:21:36 -05:00
|
|
|
func (n *Node) NewLabel(text string) *Node {
|
|
|
|
// make new node here
|
|
|
|
// n.Append(ui.NewLabel(text), false)
|
2021-11-01 03:44:39 -05:00
|
|
|
newNode := n.makeNode(text, 333, 334)
|
2021-10-31 14:21:36 -05:00
|
|
|
newNode.Dump()
|
|
|
|
// panic("node.NewLabel()")
|
|
|
|
|
|
|
|
n.Append(newNode)
|
|
|
|
return newNode
|
|
|
|
}
|
|
|
|
|
|
|
|
func (n *Node) SetText(value string) error {
|
|
|
|
log.Println("gui.SetText() value =", value)
|
|
|
|
if (n.uiText != nil) {
|
|
|
|
n.uiText.SetText(value)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if (n.uiButton != nil) {
|
|
|
|
n.uiButton.SetText(value)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-06-02 15:44:21 -05:00
|
|
|
func defaultEntryChange(e *ui.Entry) {
|
|
|
|
for key, em := range Data.AllEntries {
|
2019-06-02 17:49:52 -05:00
|
|
|
if (Config.Debug) {
|
2019-06-02 15:44:21 -05:00
|
|
|
log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em)
|
|
|
|
}
|
|
|
|
if Data.AllEntries[key].UiEntry == e {
|
|
|
|
log.Println("defaultEntryChange() FOUND",
|
2019-06-02 23:56:43 -05:00
|
|
|
"Name =", Data.AllEntries[key].Name,
|
2019-06-02 15:44:21 -05:00
|
|
|
"Last =", Data.AllEntries[key].Last,
|
|
|
|
"e.Text() =", e.Text())
|
|
|
|
Data.AllEntries[key].Last = e.Text()
|
|
|
|
if Data.AllEntries[key].Normalize != nil {
|
|
|
|
fixed := Data.AllEntries[key].Normalize(e.Text())
|
|
|
|
e.SetText(fixed)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Println("defaultEntryChange() ERROR. MISSING ENTRY MAP. e.Text() =", e.Text())
|
|
|
|
}
|
|
|
|
|
|
|
|
func defaultMakeEntry(startValue string, edit bool, action string) *GuiEntry {
|
|
|
|
e := ui.NewEntry()
|
|
|
|
e.SetText(startValue)
|
|
|
|
if (edit == false) {
|
|
|
|
e.SetReadOnly(true)
|
|
|
|
}
|
|
|
|
e.OnChanged(defaultEntryChange)
|
|
|
|
|
|
|
|
// add the entry field to the global map
|
|
|
|
var newEntry GuiEntry
|
|
|
|
newEntry.UiEntry = e
|
|
|
|
newEntry.Edit = edit
|
2019-06-02 23:56:43 -05:00
|
|
|
newEntry.Name = action
|
2019-06-02 23:01:18 -05:00
|
|
|
if (action == "INT") {
|
2019-06-02 15:44:21 -05:00
|
|
|
newEntry.Normalize = normalizeInt
|
|
|
|
}
|
|
|
|
Data.AllEntries = append(Data.AllEntries, &newEntry)
|
|
|
|
|
|
|
|
return &newEntry
|
|
|
|
}
|