2022-10-19 13:23:22 -05:00
|
|
|
package toolkit
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "os"
|
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
// make new Group here
|
|
|
|
func (t Toolkit) NewButton(name string) *Toolkit {
|
|
|
|
var newt Toolkit
|
|
|
|
var b *ui.Button
|
|
|
|
|
|
|
|
if (t.uiBox == nil) {
|
|
|
|
log.Println("gui.ToolboxNode.NewButton() node.UiBox == nil. I can't add a range UI element without a place to put it")
|
|
|
|
log.Println("probably could just make a box here?")
|
|
|
|
os.Exit(0)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("gui.Toolbox.NewGroup() create", name)
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
b = ui.NewButton(name)
|
|
|
|
newt.uiButton = b
|
|
|
|
|
|
|
|
b.OnClicked(func(*ui.Button) {
|
|
|
|
log.Println("TODO: IN TOOLKIT GOROUTINE. SHOULD LEAVE HERE VIA channels. button name =", name)
|
|
|
|
t.Dump()
|
|
|
|
newt.Dump()
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() Should do something here")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
if (newt.Custom == nil) {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() toolkit.Custom == nil")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
} else {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() START")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
newt.Custom()
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() toolkit.Custom() END")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|
|
|
|
if (t.Custom == nil) {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() parent toolkit.Custom == nil")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
} else {
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() START (IS THIS A BAD IDEA?)")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
t.Custom()
|
2022-11-05 10:19:04 -05:00
|
|
|
if (DebugToolkit) {
|
|
|
|
log.Println("wit/gui/toolkit NewButton() running parent toolkit.Custom() END (IS THIS A BAD IDEA?)")
|
|
|
|
}
|
2022-10-19 13:23:22 -05:00
|
|
|
}
|
|
|
|
log.Println("TODO: LEFT TOOLKIT GOROUTINE button name =", name)
|
|
|
|
})
|
|
|
|
|
2022-10-21 11:40:08 -05:00
|
|
|
t.uiBox.Append(b, stretchy)
|
2022-10-19 13:23:22 -05:00
|
|
|
|
|
|
|
return &newt
|
|
|
|
}
|