BOX: start node.button() funcs in the rabbit hole
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
8a87d0cb59
commit
15f9f92c62
12
box.go
12
box.go
|
@ -73,18 +73,18 @@ func add(box *GuiBox, newbox *GuiBox) {
|
|||
log.Println("gui.add() END")
|
||||
}
|
||||
|
||||
func (n *Node) NewBox(axis int, name string) *Node {
|
||||
if (n.box == nil) {
|
||||
log.Println("box == nil. I can't add a box!")
|
||||
panic("gui.Node.NewBox() node.box == nil")
|
||||
}
|
||||
|
||||
func (n *Node) AddBox(axis int, name string) *Node {
|
||||
newBox := new(GuiBox)
|
||||
newBox.Window = n.window
|
||||
newBox.Name = name
|
||||
|
||||
if (n.box == nil) {
|
||||
n.box = newBox
|
||||
}
|
||||
|
||||
// make a new box & a new node
|
||||
newNode := n.makeNode(name, 111, 100 + Config.counter)
|
||||
newNode.box = newBox
|
||||
Config.counter += 1
|
||||
|
||||
var uiBox *ui.Box
|
||||
|
|
26
button.go
26
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)
|
||||
|
|
Loading…
Reference in New Issue