mirror of https://github.com/rivo/tview.git
fixing #959 textview mouse out of bounds fix
This commit is contained in:
parent
e804876934
commit
9d79348686
7
box.go
7
box.go
|
@ -260,6 +260,13 @@ func (b *Box) InRect(x, y int) bool {
|
||||||
return x >= rectX && x < rectX+width && y >= rectY && y < rectY+height
|
return x >= rectX && x < rectX+width && y >= rectY && y < rectY+height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InRect returns true if the given coordinate is within the bounds of the box's
|
||||||
|
// rectangle.
|
||||||
|
func (b *Box) InInnerRect(x, y int) bool {
|
||||||
|
rectX, rectY, width, height := b.GetInnerRect()
|
||||||
|
return x >= rectX && x < rectX+width && y >= rectY && y < rectY+height
|
||||||
|
}
|
||||||
|
|
||||||
// GetMouseCapture returns the function installed with SetMouseCapture() or nil
|
// GetMouseCapture returns the function installed with SetMouseCapture() or nil
|
||||||
// if no such function has been installed.
|
// if no such function has been installed.
|
||||||
func (b *Box) GetMouseCapture() func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse) {
|
func (b *Box) GetMouseCapture() func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse) {
|
||||||
|
|
|
@ -1377,7 +1377,7 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
|
||||||
setFocus(t)
|
setFocus(t)
|
||||||
consumed = true
|
consumed = true
|
||||||
case MouseLeftClick:
|
case MouseLeftClick:
|
||||||
if t.regionTags {
|
if t.regionTags && t.InInnerRect(x, y) {
|
||||||
// Find a region to highlight.
|
// Find a region to highlight.
|
||||||
x -= rectX
|
x -= rectX
|
||||||
y -= rectY
|
y -= rectY
|
||||||
|
|
Loading…
Reference in New Issue