diff options
| author | Jeff Carr <[email protected]> | 2022-10-08 23:22:47 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2022-10-08 23:22:47 -0500 |
| commit | 086986b6b8f55d15d18595bcbf3f76c023365b61 (patch) | |
| tree | 9f1dc4da5b2d125f7a017418d4d9912e16b71039 /entry.go | |
| parent | f92a50e2e665a18e2201f1d6714025dcc39301cc (diff) | |
| parent | 45644ef9bc333f5def62d1c7f474dc96274e63fa (diff) | |
Merge branch 'master' into jcarr
Diffstat (limited to 'entry.go')
| -rw-r--r-- | entry.go | 112 |
1 files changed, 29 insertions, 83 deletions
@@ -1,103 +1,49 @@ package gui import "log" -import "fmt" +import "errors" +// import "fmt" import "github.com/andlabs/ui" +// import ui "git.wit.org/interesting/andlabs-ui" import _ "github.com/andlabs/ui/winmanifest" -import "github.com/davecgh/go-spew/spew" +// import "github.com/davecgh/go-spew/spew" // functions for handling text entry boxes -func NewLabel(box *GuiBox, text string) { - box.UiBox.Append(ui.NewLabel(text), false) -} +func (n *Node) NewLabel(text string) *Node { + // make new node here +newNode := n.makeNode(text, 333, 334) + newNode.Dump() -func GetText(box *GuiBox, name string) string { - if (box == nil) { - log.Println("gui.GetText() ERROR box == nil") - return "" - } - if (box.Window.EntryMap == nil) { - log.Println("gui.GetText() ERROR b.Box.Window.EntryMap == nil") - return "" - } - spew.Dump(box.Window.EntryMap) - if (box.Window.EntryMap[name] == nil) { - log.Println("gui.GetText() ERROR box.Window.EntryMap[", name, "] == nil ") - return "" - } - e := box.Window.EntryMap[name] - log.Println("gui.GetText() box.Window.EntryMap[", name, "] = ", e.UiEntry.Text()) - log.Println("gui.GetText() END") - return e.UiEntry.Text() + n.Append(newNode) + return newNode } -func SetText(box *GuiBox, name string, value string) error { - if (box == nil) { - return fmt.Errorf("gui.SetText() ERROR box == nil") +func (n *Node) SetText(value string) error { + log.Println("gui.SetText() value =", value) + if (n.uiText != nil) { + n.uiText.SetText(value) + return nil } - if (box.Window.EntryMap == nil) { - return fmt.Errorf("gui.SetText() ERROR b.Box.Window.EntryMap == nil") + if (n.uiButton != nil) { + n.uiButton.SetText(value) + return nil } - spew.Dump(box.Window.EntryMap) - if (box.Window.EntryMap[name] == nil) { - return fmt.Errorf("gui.SetText() ERROR box.Window.EntryMap[", name, "] == nil ") + if (n.uiMultilineEntry != nil) { + n.uiMultilineEntry.SetText(value) + return 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 + n.Dump() + return errors.New("couldn't find something to set the text to") } -func MakeEntryHbox(box *GuiBox, a string, startValue string, edit bool, action string) *GuiEntry { - // Start 'Nickname' vertical box - hboxN := ui.NewHorizontalBox() - hboxN.SetPadded(true) - hboxN.Append(ui.NewLabel(a), false) - - e := defaultMakeEntry(startValue, edit, action) - hboxN.Append(e.UiEntry, false) - - box.UiBox.Append(hboxN, false) - // End 'Nickname' vertical box - - 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 (n *Node) SetMargined(x bool) { + if (n.uiGroup != nil) { + n.uiGroup.SetMargined(x) + return + } + log.Println("Couldn't find something that has a Margin setting") } func defaultEntryChange(e *ui.Entry) { |
