correctly dereference the AreaHandler

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 11:10:12 -07:00
parent 1399f2b695
commit c24d78fac2
2 changed files with 16 additions and 17 deletions

28
area.go
View File

@ -20,12 +20,11 @@ func findFB(button *ButtonMap) *ButtonMap {
return a return a
} }
func makeSplashArea() *AreaHandler { func makeSplashArea(ah *AreaHandler) {
// make this button just to get the default font (but don't display the button) // make this button just to get the default font (but don't display the button)
// There should be another way to do this (?) // There should be another way to do this (?)
myAH = new(AreaHandler)
newB := CreateFontButton("AREA") newB := CreateFontButton("AREA")
myAH.FontButton = newB.FB ah.FontButton = newB.FB
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
tmp := findFB(newB) tmp := findFB(newB)
@ -39,30 +38,29 @@ func makeSplashArea() *AreaHandler {
tmp = findFB(newB) tmp = findFB(newB)
log.Println("makeSplashArea() tmp =", tmp, "newB", newB) log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
Data.AllButtons[1].AH = myAH Data.AllButtons[1].AH = ah
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
tmp = findFB(newB) tmp = findFB(newB)
log.Println("makeSplashArea() tmp =", tmp, "newB", newB) log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
// log.Println("makeSplashArea() ah =", myAH) // log.Println("makeSplashArea() ah =", ah)
log.Println("makeSplashArea() ah.FontButton =", myAH.FontButton) log.Println("makeSplashArea() ah.FontButton =", ah.FontButton)
// DefaultFont: ah.FontButton.Font(), // DefaultFont: ah.FontButton.Font(),
myAH.Attrstr = makeAttributedString() ah.Attrstr = makeAttributedString()
myAH.Area = ui.NewArea(myAH) ah.Area = ui.NewArea(ah)
newB.A = myAH.Area newB.A = ah.Area
Data.AllButtons[1].A = myAH.Area Data.AllButtons[1].A = ah.Area
myAH.FontButton = Data.AllButtons[1].FB ah.FontButton = Data.AllButtons[1].FB
myAH.Button = &Data.AllButtons[1] ah.Button = &Data.AllButtons[1]
if (Data.Debug) { if (Data.Debug) {
spew.Dump(myAH.Area) spew.Dump(ah.Area)
log.Println("DEBUGGING", Data.Debug) log.Println("DEBUGGING", Data.Debug)
} else { } else {
log.Println("NOT DEBUGGING AREA mhAH.Button =", myAH.Button) log.Println("NOT DEBUGGING AREA mhAH.Button =", ah.Button)
} }
return myAH
} }
func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) { func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {

View File

@ -14,12 +14,13 @@ func ShowSplashBox() *ui.Box {
newbox := ui.NewVerticalBox() newbox := ui.NewVerticalBox()
newbox.SetPadded(true) newbox.SetPadded(true)
// initialize the AreaHandler{}
myAH = new(AreaHandler) myAH = new(AreaHandler)
newText := makeAttributedString() newText := makeAttributedString()
myAH.Attrstr = newText myAH.Attrstr = newText
newAH := makeSplashArea() makeSplashArea(myAH)
newbox.Append(newAH.Area, true) newbox.Append(myAH.Area, true)
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
newbox.Append(ui.NewLabel("OS: Linux"), false) newbox.Append(ui.NewLabel("OS: Linux"), false)