diff options
| -rw-r--r-- | box.go | 12 | ||||
| -rw-r--r-- | button.go | 26 | ||||
| -rw-r--r-- | find.go | 7 |
3 files changed, 39 insertions, 6 deletions
@@ -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 @@ -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) @@ -18,6 +18,13 @@ func (n *Node) FindControl() *ui.Control { } func (n *Node) FindBox() *GuiBox { + if (n.box != nil) { + return n.box + } + if (n.parent != nil) { + p := n.parent + return p.box + } return n.box } |
