Skip to content

Commit

Permalink
Check for collisions in reverse view order
Browse files Browse the repository at this point in the history
  • Loading branch information
telecoda authored and jroimartin committed Aug 15, 2017
1 parent c48e902 commit 4316bb7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ func (g *Gui) View(name string) (*View, error) {
// ViewByPosition returns a pointer to a view matching the given position, or
// error ErrUnknownView if a view in that position does not exist.
func (g *Gui) ViewByPosition(x, y int) (*View, error) {
for _, v := range g.views {

// 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 {
return v, nil
}
Expand Down

0 comments on commit 4316bb7

Please sign in to comment.