tui/views/eventview.go

28 lines
500 B
Go
Raw Normal View History

2021-01-10 21:52:29 +01:00
package views
import (
2022-04-01 20:10:51 +02:00
"git.tordarus.net/Tordarus/tui"
2021-01-10 21:52:29 +01:00
)
type EventView struct {
2022-04-01 20:10:51 +02:00
tui.WrapperTmpl
View tui.View
KeyPressed func(event *tui.KeyEvent) (consumed bool)
}
func NewEventView(view tui.View) *EventView {
return &EventView{View: view}
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *EventView) OnKeyPressed(event *tui.KeyEvent) (consumed bool) {
2021-01-10 21:52:29 +01:00
if v.KeyPressed != nil {
2022-04-01 20:10:51 +02:00
return v.KeyPressed(event)
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
return v.ViewTmpl.OnKeyPressed(event)
2021-01-10 21:52:29 +01:00
}
2022-04-01 20:10:51 +02:00
func (v *EventView) Draw(buf *tui.ViewBuffer) {
v.View.Draw(buf)
2021-01-10 21:52:29 +01:00
}