summaryrefslogtreecommitdiff
path: root/button.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2021-10-28 19:47:49 -0500
committerJeff Carr <[email protected]>2021-10-28 19:47:49 -0500
commit5a838262bdc72e51351d0d81efcd9b2825e5e525 (patch)
tree49a2722c1d79c8d59f736fd13012750e56dea602 /button.go
parent5cff6a1acef806e263191fcb58bd68ac4a7287ea (diff)
BOX: start node.button() funcs in the rabbit hole
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'button.go')
-rw-r--r--button.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/button.go b/button.go
index 825b79b..d616178 100644
--- a/button.go
+++ b/button.go
@@ -50,6 +50,32 @@ func guiButtonClick(button *GuiButton) {
}
}
+func (n *Node) CreateButton(custom func(*GuiButton), name string, values interface {}) *Node {
+ newNode := n.AddBox(Xaxis, "test")
+ box := newNode.FindBox()
+ if (box == nil) {
+ panic("node.CreateButton().FindBox() == nil")
+ }
+ newUiB := ui.NewButton(name)
+ newUiB.OnClicked(defaultButtonClick)
+
+ var newB *GuiButton
+ newB = new(GuiButton)
+ newB.B = newUiB
+ if (box.UiBox == nil) {
+ log.Println("CreateButton() box.Window == nil")
+ // ErrorWindow(box.Window, "Login Failed", msg) // can't even do this
+ panic("maybe print an error and return nil? or make a fake button?")
+ }
+ newB.Box = box
+ newB.Custom = custom
+ newB.Values = values
+
+ Data.AllButtons = append(Data.AllButtons, newB)
+
+ box.Append(newB.B, false)
+ return newNode
+}
func CreateButton(box *GuiBox, custom func(*GuiButton), name string, values interface {}) *GuiButton {
newUiB := ui.NewButton(name)
newUiB.OnClicked(defaultButtonClick)