correct custom Area mouse click

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2019-06-01 22:24:10 -07:00
parent d95e62aaea
commit a9c621d503
2 changed files with 7 additions and 5 deletions

11
area.go
View File

@ -9,12 +9,13 @@ import "github.com/davecgh/go-spew/spew"
// THIS IS CLEAN
func makeGenericArea(gb *GuiBox, newText *ui.AttributedString) {
func makeGenericArea(gb *GuiBox, newText *ui.AttributedString, custom func(*GuiButton)) {
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
var newB *GuiButton
newB = CreateFontButton(gb, "AREA")
newB.Box = gb
newB.custom = custom
newB.GW = gb.Window
gw := gb.Window
@ -76,7 +77,9 @@ func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP ah.Button =", ah.Button)
log.Println("GOT MOUSE UP ah.Button.FB =", ah.Button.FB)
if (Data.MouseClick != nil) {
if (ah.Button.custom != nil) {
ah.Button.custom(ah.Button)
} else if (Data.MouseClick != nil) {
Data.MouseClick(ah.Button)
}
}
@ -107,7 +110,7 @@ func (ah GuiArea) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
return false
}
func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiButton)) *GuiBox {
log.Println("ShowTextBox() START")
if (gw == nil) {
log.Println("ShowTextBox() ERROR gw = nil")
@ -117,7 +120,7 @@ func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString) *GuiBox {
box := InitGuiBox(gw, nil, ui.NewVerticalBox(), "SplashArea3")
makeGenericArea(box, newText)
makeGenericArea(box, newText, custom)
box.UiBox.Append(box.Window.Area.UiArea, true)
return box

1
gui.go
View File

@ -197,7 +197,6 @@ func CreateFontButton(box *GuiBox, action string) *GuiButton {
newGB.Action = action
newGB.FB = ui.NewFontButton()
newGB.Box = box
// newGB.Area = box.Window.Area
Data.AllButtons = append(Data.AllButtons, &newGB)
newGB.FB.OnChanged(func (*ui.FontButton) {