Sander Schobers
9641719579
Refactored event handling to be able to "handle" events so no other controls will handle the same event again.
54 lines
945 B
Go
54 lines
945 B
Go
package tins2020
|
|
|
|
type Dialogs struct {
|
|
Proxy
|
|
|
|
intro Control
|
|
settings Control
|
|
|
|
dialogClosed *Events
|
|
dialogOpened *Events
|
|
}
|
|
|
|
func NewDialogs() *Dialogs {
|
|
return &Dialogs{
|
|
dialogClosed: NewEvents(),
|
|
dialogOpened: NewEvents(),
|
|
}
|
|
}
|
|
|
|
func (d *Dialogs) DialogClosed() EventHandler { return d.dialogClosed }
|
|
func (d *Dialogs) DialogOpened() EventHandler { return d.dialogOpened }
|
|
|
|
func (d *Dialogs) Init(ctx *Context) error {
|
|
d.intro = &Intro{}
|
|
d.settings = &DialogBase{}
|
|
|
|
err := d.intro.Init(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = d.settings.Init(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (d *Dialogs) Close() {
|
|
d.Proxied = nil
|
|
d.dialogClosed.Notify(nil)
|
|
}
|
|
|
|
func (d *Dialogs) ShowIntro() {
|
|
d.Proxied = d.intro
|
|
d.intro.(Dialog).ShowDialog(d.Close)
|
|
d.dialogOpened.Notify(nil)
|
|
}
|
|
|
|
func (d *Dialogs) ShowSettings() {
|
|
d.Proxied = d.settings
|
|
d.settings.(Dialog).ShowDialog(d.Close)
|
|
d.dialogOpened.Notify(nil)
|
|
}
|