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) newLabel(&a)
return return
case toolkit.Button: case toolkit.Button:
newButton(&a) p.newButton(n)
return return
case toolkit.Grid: case toolkit.Grid:
newGrid(&a) newGrid(&a)

View File

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