Created
November 27, 2011 16:32
-
-
Save sohocoke/1397766 to your computer and use it in GitHub Desktop.
inpecting NSView hierarchy with MacRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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