NODE: switch more around
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
5ad39c8df9
commit
73006c8b5e
27
button.go
27
button.go
|
@ -1,10 +1,12 @@
|
|||
package gui
|
||||
|
||||
import "log"
|
||||
import "reflect"
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
|
||||
// This is the default mouse click handler
|
||||
// Every mouse click that hasn't been assigned to
|
||||
// something specific will fall into this routine
|
||||
|
@ -50,6 +52,30 @@ func guiButtonClick(button *GuiButton) {
|
|||
}
|
||||
}
|
||||
|
||||
func (n *Node) AddButton(name string, custom func(*Node)) *Node {
|
||||
if (n.uiBox == nil) {
|
||||
log.Println("gui.Node.AppendButton() filed node.UiBox == nil")
|
||||
return n
|
||||
}
|
||||
button := ui.NewButton(name)
|
||||
log.Println("reflect.TypeOF(uiBox) =", reflect.TypeOf(n.uiBox))
|
||||
log.Println("reflect.TypeOF(uiButton) =", reflect.TypeOf(button))
|
||||
n.uiBox.Append(button, false)
|
||||
n.uiButton = button
|
||||
|
||||
newNode := n.makeNode(name, 888, 888 + Config.counter)
|
||||
newNode.uiButton = button
|
||||
newNode.custom = custom
|
||||
|
||||
button.OnClicked(func(*ui.Button) {
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom()")
|
||||
custom(newNode)
|
||||
})
|
||||
// panic("AppendButton")
|
||||
// time.Sleep(3 * time.Second)
|
||||
return newNode
|
||||
}
|
||||
|
||||
func (n *Node) CreateButton(custom func(*GuiButton), name string, values interface {}) *Node {
|
||||
newNode := n.AddBox(Xaxis, "test CreateButton")
|
||||
box := newNode.FindBox()
|
||||
|
@ -79,6 +105,7 @@ func (n *Node) CreateButton(custom func(*GuiButton), name string, values interfa
|
|||
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)
|
||||
|
|
|
@ -3,7 +3,7 @@ package gui
|
|||
import (
|
||||
"log"
|
||||
"fmt"
|
||||
"reflect"
|
||||
// "reflect"
|
||||
|
||||
// "github.com/davecgh/go-spew/spew"
|
||||
|
||||
|
@ -124,30 +124,6 @@ func (n *Node) Append(child *Node) {
|
|||
// time.Sleep(3 * time.Second)
|
||||
}
|
||||
|
||||
func (n *Node) AddButton(name string, custom func(*Node)) *Node {
|
||||
if (n.uiBox == nil) {
|
||||
log.Println("gui.Node.AppendButton() filed node.UiBox == nil")
|
||||
return n
|
||||
}
|
||||
button := ui.NewButton(name)
|
||||
log.Println("reflect.TypeOF(uiBox) =", reflect.TypeOf(n.uiBox))
|
||||
log.Println("reflect.TypeOF(uiButton) =", reflect.TypeOf(button))
|
||||
n.uiBox.Append(button, false)
|
||||
n.uiButton = button
|
||||
|
||||
newNode := n.makeNode(name, 888, 888 + Config.counter)
|
||||
newNode.uiButton = button
|
||||
newNode.custom = custom
|
||||
|
||||
button.OnClicked(func(*ui.Button) {
|
||||
log.Println("gui.AppendButton() Button Clicked. Running custom()")
|
||||
custom(newNode)
|
||||
})
|
||||
// panic("AppendButton")
|
||||
// time.Sleep(3 * time.Second)
|
||||
return newNode
|
||||
}
|
||||
|
||||
func (n *Node) List() {
|
||||
findByIdDFS(n, "test")
|
||||
}
|
||||
|
@ -254,7 +230,6 @@ func (n *Node) AddTabNode(title string, b *GuiBox) *Node {
|
|||
return newNode
|
||||
}
|
||||
|
||||
// func (parent *Node) AddTab(title string, uiC ui.Control) *Node {
|
||||
func (n *Node) AddTab(title string, uiC *ui.Box) *Node {
|
||||
parent := n
|
||||
log.Println("gui.Node.AddTab() START name =", title)
|
||||
|
|
Loading…
Reference in New Issue