aboutsummaryrefslogtreecommitdiffstats
path: root/ui/ui.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/ui/ui.go b/ui/ui.go
index d1d2ca3d..9ea037c3 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -11,6 +11,8 @@ type UI struct {
Content Drawable
ctx *Context
+ interactive []Interactive
+
tbEvents chan tb.Event
invalidations chan interface{}
}
@@ -58,6 +60,11 @@ func (state *UI) Tick() bool {
state.ctx = NewContext(event.Width, event.Height)
state.Content.Invalidate()
}
+ if state.interactive != nil {
+ for _, i := range state.interactive {
+ i.Event(event)
+ }
+ }
case <-state.invalidations:
state.Content.Draw(state.ctx)
tb.Flush()
@@ -66,3 +73,7 @@ func (state *UI) Tick() bool {
}
return true
}
+
+func (state *UI) AddInteractive(i Interactive) {
+ state.interactive = append(state.interactive, i)
+}