tins2020/content.go
Sander Schobers 9641719579 Added intro dialog.
Refactored event handling to be able to "handle" events so no other controls will handle the same event again.
2020-05-11 11:44:50 +02:00

29 lines
563 B
Go

package tins2020
import "github.com/veandco/go-sdl2/sdl"
// Content shortcuts events when a dialog is opened.
type Content struct {
Container
dialogOverlayed bool
}
func NewContent(dialogs *Dialogs) *Content {
content := &Content{}
dialogs.DialogOpened().Register(func() {
content.dialogOverlayed = true
})
dialogs.DialogClosed().Register(func() {
content.dialogOverlayed = false
})
return content
}
func (c *Content) Handle(ctx *Context, event sdl.Event) bool {
if c.dialogOverlayed {
return false
}
return c.Container.Handle(ctx, event)
}