From fbee749187dcd99133eef97d2bd4a0e07ceb0bd2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 27 Apr 2023 09:59:19 -0500 Subject: [PATCH] andlabs: button in binary tree Signed-off-by: Jeff Carr --- toolkit/andlabs/add.go | 2 +- toolkit/andlabs/button.go | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/toolkit/andlabs/add.go b/toolkit/andlabs/add.go index 95a637a..bca7aa9 100644 --- a/toolkit/andlabs/add.go +++ b/toolkit/andlabs/add.go @@ -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) diff --git a/toolkit/andlabs/button.go b/toolkit/andlabs/button.go index f4032d0..b3eae7b 100644 --- a/toolkit/andlabs/button.go +++ b/toolkit/andlabs/button.go @@ -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) }