crib/statustextview.go
2020-10-03 21:26:32 -07:00

34 lines
812 B
Go

package main
import (
"github.com/gdamore/tcell/v2"
"gitlab.com/tslocum/cview"
)
type statusTextView struct {
*cview.TextView
}
func newStatusTextView() *statusTextView {
return &statusTextView{cview.NewTextView()}
}
// MouseHandler returns the mouse handler for this primitive.
func (t *statusTextView) MouseHandler() func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive) {
return t.WrapMouseHandler(func(action cview.MouseAction, event *tcell.EventMouse, setFocus func(p cview.Primitive)) (consumed bool, capture cview.Primitive) {
x, y := event.Position()
if !t.InRect(x, y) {
return false, nil
}
switch action {
case cview.MouseLeftClick:
doAction()
consumed = true
setFocus(t)
}
return
})
}