fix crash

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-05-29 11:07:14 -07:00
parent 639d636769
commit 1399f2b695
4 changed files with 12 additions and 8 deletions

10
area.go
View File

@ -23,6 +23,7 @@ func findFB(button *ButtonMap) *ButtonMap {
func makeSplashArea() *AreaHandler {
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
myAH = new(AreaHandler)
newB := CreateFontButton("AREA")
myAH.FontButton = newB.FB
@ -38,7 +39,7 @@ func makeSplashArea() *AreaHandler {
tmp = findFB(newB)
log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
Data.AllButtons[1].AH = &myAH
Data.AllButtons[1].AH = myAH
time.Sleep(200 * time.Millisecond)
tmp = findFB(newB)
@ -61,7 +62,7 @@ func makeSplashArea() *AreaHandler {
} else {
log.Println("NOT DEBUGGING AREA mhAH.Button =", myAH.Button)
}
return &myAH
return myAH
}
func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {
@ -94,8 +95,9 @@ func (ah AreaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
}
if (me.Up == 1) {
log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP")
// log.Println("GOT MOUSE UP ah", ah)
log.Println("GOT MOUSE UP ah.FontButton =", ah.FontButton)
log.Println("GOT MOUSE UP ah.Button =", ah.Button)
mouseClick(ah.Button)
}
}

5
gui.go
View File

@ -232,11 +232,12 @@ func CreateFontButton(action string) *ButtonMap {
var newBM ButtonMap
newBM.Action = action
newBM.FB = newB
newBM.AH = &myAH
newBM.AH = myAH
Data.AllButtons = append(Data.AllButtons, newBM)
newB.OnChanged(func (*ui.FontButton) {
mouseClick(&newBM)
log.Println("FontButton.OnChanged() START mouseClick(&newBM)", &newBM)
// mouseClick(&newBM)
})
return &newBM
}

View File

@ -14,6 +14,7 @@ func ShowSplashBox() *ui.Box {
newbox := ui.NewVerticalBox()
newbox.SetPadded(true)
myAH = new(AreaHandler)
newText := makeAttributedString()
myAH.Attrstr = newText
newAH := makeSplashArea()

View File

@ -13,7 +13,7 @@ import pb "git.wit.com/wit/witProtobuf"
// be the safe way to interact with the GUI
//
var Data GuiDataStructure
var myAH AreaHandler
var myAH *AreaHandler
type GuiDataStructure struct {
State string
@ -119,7 +119,7 @@ type AreaHandler struct{
Attrstr *ui.AttributedString
Area *ui.Area
FontButton *ui.FontButton
FB func () *ButtonMap
// FB func () *ButtonMap
}
// AREA STRUCTURES END