Skip to content

Commit

Permalink
fixing rivo#959 textview mouse out of bounds fix
Browse files Browse the repository at this point in the history
  • Loading branch information
digitallyserviced authored and kopecmaciej committed Aug 27, 2024
1 parent d665bcd commit c844b2b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions box.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ func (b *Box) InRect(x, y int) bool {
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
// if no such function has been installed.
func (b *Box) GetMouseCapture() func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse) {
Expand Down
2 changes: 1 addition & 1 deletion textview.go
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ func (t *TextView) MouseHandler() func(action MouseAction, event *tcell.EventMou
setFocus(t)
consumed = true
case MouseLeftClick:
if t.regionTags {
if t.regionTags && t.InInnerRect(x, y) {
// Find a region to highlight.
x -= rectX
y -= rectY
Expand Down

0 comments on commit c844b2b

Please sign in to comment.