Cribbage.World terminal-based client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
812 B

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
})
}