Skip to content

Instantly share code, notes, and snippets.

Created October 3, 2012 04:41
Show Gist options
  • Save anonymous/3825036 to your computer and use it in GitHub Desktop.
Save anonymous/3825036 to your computer and use it in GitHub Desktop.
widgetAtPoint: (point) ->
_widgetsInTouch = []
for widget,i in @widgets
continue if widget instanceof App.Views.TextWidget
if widget.getIsVisible() and widget.isPointInside(point)
_widgetsInTouch[i] = widget
if _widgetsInTouch.length > 1
_widgetsInTouch.sort (a, b) ->
compA = a.getZOrder()
compB = b.getZOrder()
if compB < compA then -1 else (if compB > compA then 1 else 0)
return _widgetsInTouch[0]
if _widgetsInTouch.length == 1
return _widgetsInTouch[0]
null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment