Skip to content

Instantly share code, notes, and snippets.

@sohocoke
Created November 27, 2011 16:32
Show Gist options
  • Save sohocoke/1397766 to your computer and use it in GitHub Desktop.
Save sohocoke/1397766 to your computer and use it in GitHub Desktop.
inpecting NSView hierarchy with MacRuby
class NSView
def view_tree
self.view_where { true }
end
def views_where(&block)
# traverse view hierarchy and collect views matching condition.
hits = []
hits << self if yield self
self.subviews.each do |subview|
subview_hits = subview.views_where(&block)
hits << subview_hits if ! subview_hits.empty?
end
hits
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment