diff options
| author | Jeff Carr <[email protected]> | 2019-06-02 13:44:21 -0700 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2019-06-02 13:44:21 -0700 |
| commit | 16008fefad4573af5e0c5bc9909f0e5114863ec6 (patch) | |
| tree | e5b2f252552b18dbc67fec7141872c01eb0cdddf /entry.go | |
| parent | c7402944c58285a3fd38b2b4678fdc97ada768a2 (diff) | |
finally can phase out misc.go
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'entry.go')
| -rw-r--r-- | entry.go | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -101,3 +101,45 @@ func AddEntry(box *GuiBox, name string) *GuiEntry { return ge } + +func defaultEntryChange(e *ui.Entry) { + for key, em := range Data.AllEntries { + if (Data.Debug) { + log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em) + } + if Data.AllEntries[key].UiEntry == e { + log.Println("defaultEntryChange() FOUND", + "action =", Data.AllEntries[key].Action, + "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 + newEntry.Action = action + if (action == "Memory") { + newEntry.Normalize = normalizeInt + } + Data.AllEntries = append(Data.AllEntries, &newEntry) + + return &newEntry +} |
