mirror of https://github.com/rivo/tview.git
Clarifications on mouse handling, resolves #667
This commit is contained in:
parent
2245e5062d
commit
a22293bda9
8
box.go
8
box.go
|
@ -248,6 +248,10 @@ func (b *Box) MouseHandler() func(action MouseAction, event *tcell.EventMouse, s
|
||||||
// called.
|
// called.
|
||||||
//
|
//
|
||||||
// Providing a nil handler will remove a previously existing handler.
|
// Providing a nil handler will remove a previously existing handler.
|
||||||
|
//
|
||||||
|
// Note that mouse events are ignored completely if the application has not been
|
||||||
|
// enabled for mouse events (see [Application.EnableMouse]), which is the
|
||||||
|
// default.
|
||||||
func (b *Box) SetMouseCapture(capture func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse)) *Box {
|
func (b *Box) SetMouseCapture(capture func(action MouseAction, event *tcell.EventMouse) (MouseAction, *tcell.EventMouse)) *Box {
|
||||||
b.mouseCapture = capture
|
b.mouseCapture = capture
|
||||||
return b
|
return b
|
||||||
|
@ -260,8 +264,8 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// InInnerRect returns true if the given coordinate is within the bounds of the box's
|
// InInnerRect returns true if the given coordinate is within the bounds of the
|
||||||
// inner rectangle (within the border, and padding).
|
// box's inner rectangle (within the border and padding).
|
||||||
func (b *Box) InInnerRect(x, y int) bool {
|
func (b *Box) InInnerRect(x, y int) bool {
|
||||||
rectX, rectY, width, height := b.GetInnerRect()
|
rectX, rectY, width, height := b.GetInnerRect()
|
||||||
return x >= rectX && x < rectX+width && y >= rectY && y < rectY+height
|
return x >= rectX && x < rectX+width && y >= rectY && y < rectY+height
|
||||||
|
|
7
doc.go
7
doc.go
|
@ -158,6 +158,13 @@ switch to a light (or other) theme.
|
||||||
|
|
||||||
This package supports all unicode characters supported by your terminal.
|
This package supports all unicode characters supported by your terminal.
|
||||||
|
|
||||||
|
# Mouse Support
|
||||||
|
|
||||||
|
If your terminal supports mouse events, you can enable mouse support for your
|
||||||
|
application by calling [Application.EnableMouse]. Note that this may interfere
|
||||||
|
with your terminal's default mouse behavior. Mouse support is disabled by
|
||||||
|
default.
|
||||||
|
|
||||||
# Concurrency
|
# Concurrency
|
||||||
|
|
||||||
Many functions in this package are not thread-safe. For many applications, this
|
Many functions in this package are not thread-safe. For many applications, this
|
||||||
|
|
Loading…
Reference in New Issue