diff options
| author | Jeff Carr <[email protected]> | 2022-10-16 08:07:13 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-10-16 08:07:13 -0500 |
| commit | 2141e04328dcf4e4d6857fcc0a7cb551fc84fa07 (patch) | |
| tree | f8b2a5d8cf17f9ccfcfa8c1699fe4a52ea8338e2 /entry.go | |
| parent | 3c899365154e48aefbc0b5ee48cd089f49339cb2 (diff) | |
Add slander and spinbox in toolkit/andlabs
fix the helloworld demo
move slider into toolkit/
move more into the toolkit directory
add spinbox()
fix example
minor update
fix examples
Fix andlabs.ui.Slider() to work again
correctly implement custom OnChange() callback
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'entry.go')
| -rw-r--r-- | entry.go | 111 |
1 files changed, 1 insertions, 110 deletions
@@ -1,7 +1,7 @@ package gui import "log" -import "fmt" +// import "fmt" import "github.com/andlabs/ui" import _ "github.com/andlabs/ui/winmanifest" @@ -15,10 +15,8 @@ func NewLabel(box *GuiBox, text string) { func (n *Node) NewLabel(text string) *Node { // make new node here - // n.Append(ui.NewLabel(text), false) newNode := makeNode(n, text, 333, 334) newNode.Dump() - // panic("node.NewLabel()") n.Append(newNode) return newNode @@ -52,110 +50,3 @@ func (n *Node) SetText(value string) error { } return nil } - -func SetText(box *GuiBox, name string, value string) error { - if (box == nil) { - return fmt.Errorf("gui.SetText() ERROR box == nil") - } - if (box.Window.EntryMap == nil) { - return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil") - } - spew.Dump(box.Window.EntryMap) - if (box.Window.EntryMap[name] == nil) { - return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[" + name + "] == nil ") - } - e := box.Window.EntryMap[name] - log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - e.UiEntry.SetText(value) - log.Println("gui.SetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - log.Println("gui.SetText() END") - return nil -} - -// makeEntryBox(box, "hostname:", "blah.foo.org") { -func MakeEntryVbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { - // Start 'Nickname' vertical box - vboxN := ui.NewVerticalBox() - vboxN.SetPadded(true) - vboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - - vboxN.Append(e.UiEntry, false) - box.UiBox.Append(vboxN, false) - // End 'Nickname' vertical box - - return e -} - -func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { - hboxN := ui.NewHorizontalBox() - hboxN.SetPadded(true) - hboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - hboxN.Append(e.UiEntry, true) - - box.UiBox.Append(hboxN, true) - - return e -} - -func AddEntry(box *GuiBox, name string) *GuiEntry { - var ge *GuiEntry - ge = new(GuiEntry) - - ue := ui.NewEntry() - ue.SetReadOnly(false) - ue.OnChanged(func(*ui.Entry) { - log.Println("gui.AddEntry() OK. ue.Text() =", ue.Text()) - }) - box.UiBox.Append(ue, false) - - ge.UiEntry = ue - box.Window.EntryMap[name] = ge - - return ge -} - -func defaultEntryChange(e *ui.Entry) { - for key, em := range Data.AllEntries { - if (Config.Debug) { - log.Println("\tdefaultEntryChange() Data.AllEntries =", key, em) - } - if Data.AllEntries[key].UiEntry == e { - log.Println("defaultEntryChange() FOUND", - "Name =", Data.AllEntries[key].Name, - "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.Name = action - if (action == "INT") { - newEntry.Normalize = normalizeInt - } - Data.AllEntries = append(Data.AllEntries, &newEntry) - - return &newEntry -} |
