andlabs: button in binary tree

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2023-04-27 09:59:19 -05:00
parent bec9a99a15
commit fbee749187
2 changed files with 11 additions and 15 deletions

View File

@ -39,7 +39,7 @@ func add(a toolkit.Action) {
newLabel(&a)
return
case toolkit.Button:
newButton(&a)
p.newButton(n)
return
case toolkit.Grid:
newGrid(&a)

View File

@ -3,34 +3,30 @@ package main
import (
"github.com/andlabs/ui"
_ "github.com/andlabs/ui/winmanifest"
"git.wit.org/wit/gui/toolkit"
)
func newButton(a *toolkit.Action) {
var t, newt *andlabsT
var b *ui.Button
log(debugToolkit, "newButton()", a.Name)
func (p *node) newButton(n *node) {
log(debugToolkit, "newButton()", n.Name)
t = andlabs[a.ParentId]
t := p.tk
if (t == nil) {
log(debugToolkit, "newButton() toolkit struct == nil. name=", a.Name)
log(debugToolkit, "newButton() toolkit struct == nil. name=", n.Name)
return
}
newt = new(andlabsT)
newt := new(andlabsT)
b = ui.NewButton(a.Text)
b := ui.NewButton(n.Text)
newt.uiButton = b
newt.uiControl = b
newt.wId = a.WidgetId
newt.WidgetType = a.WidgetType
newt.wId = n.WidgetId
newt.WidgetType = n.WidgetType
newt.parent = t
place(a, t, newt)
b.OnClicked(func(*ui.Button) {
newt.doUserEvent()
})
n.tk = newt
p.place(n)
}