mirror of
https://github.com/jroimartin/gocui.git
synced 2025-04-28 13:48:51 +08:00
extend mouse events to include view frame edges
This commit is contained in:
parent
e030e03fac
commit
d99ac1a5a2
6
gui.go
6
gui.go
@ -233,7 +233,11 @@ func (g *Gui) ViewByPosition(x, y int) (*View, error) {
|
||||
// traverse views in reverse order checking top views first
|
||||
for i := len(g.views); i > 0; i-- {
|
||||
v := g.views[i-1]
|
||||
if x > v.x0 && x < v.x1 && y > v.y0 && y < v.y1 {
|
||||
frameOffset := 0
|
||||
if v.Frame {
|
||||
frameOffset = 1
|
||||
}
|
||||
if x > v.x0-frameOffset && x < v.x1+frameOffset && y > v.y0-frameOffset && y < v.y1+frameOffset {
|
||||
return v, nil
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user