fix andlabs.ui.NewLabel()

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2022-10-16 10:09:16 -05:00
parent fbf97443d5
commit a03d2f7c97
3 changed files with 34 additions and 4 deletions

View File

@ -3,8 +3,12 @@ package gui
import "log" import "log"
// import "fmt" // import "fmt"
import toolkit "git.wit.org/wit/gui/toolkit/andlabs"
import "github.com/andlabs/ui" import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest" import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew" import "github.com/davecgh/go-spew/spew"
// functions for handling text entry boxes // functions for handling text entry boxes
@ -18,7 +22,9 @@ func (n *Node) NewLabel(text string) *Node {
newNode := makeNode(n, text, 333, 334) newNode := makeNode(n, text, 333, 334)
newNode.Dump() newNode.Dump()
n.Append(newNode) t := toolkit.NewLabel(n.uiBox, text)
newNode.Toolkit = t
return newNode return newNode
} }

23
toolkit/andlabs/label.go Normal file
View File

@ -0,0 +1,23 @@
package toolkit
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
func NewLabel(b *ui.Box, name string) *Toolkit {
// make new node here
log.Println("gui.Toolbox.NewLabel", name)
var t Toolkit
if (b == nil) {
log.Println("gui.ToolboxNode.NewLabel() node.UiBox == nil. I can't add a range UI element without a place to put it")
return &t
}
l := ui.NewLabel(name)
t.uiLabel = l
t.uiBox = b
t.uiBox.Append(l, false)
return &t
}

View File

@ -19,14 +19,15 @@ type Toolkit struct {
OnChanged func(*Toolkit) OnChanged func(*Toolkit)
uiControl *ui.Control uiBox *ui.Box
uiButton *ui.Button uiButton *ui.Button
uiControl *ui.Control
uiLabel *ui.Label
uiSlider *ui.Slider uiSlider *ui.Slider
uiSpinbox *ui.Spinbox uiSpinbox *ui.Spinbox
uiWindow *ui.Window
uiTab *ui.Tab uiTab *ui.Tab
uiBox *ui.Box
uiText *ui.EditableCombobox uiText *ui.EditableCombobox
uiWindow *ui.Window
} }
func (t *Toolkit) Value() int { func (t *Toolkit) Value() int {