Sha256: 0f38c1aee469aca704575381cc057cdcdfc74ead3aaeebea46c80e515b27022a

Contents?: true

Size: 890 Bytes

Versions: 5

Compression:

Stored size: 890 Bytes

Contents

# Methods to retrieve a subview using the stylename as a key
# Kinda similar to jQuery-style $().find('stylename')
class UIView

  # get one stylesheet by stylename
  # my_view[:button] :button => #<UIButton..>
  def viewWithStylename name
    view = subviews.find {|view| view.stylename == name}
    return view if view

    # found_subview will get assigned to the view we want, but the subview is
    # what is returned.
    found_subview = nil
    view = subviews.find {|subview| found_subview = subview.viewWithStylename(name) }
    return found_subview if view

    nil  # couldn't find it
  end

  # get stylesheets by stylename
  # my_view.all :button => [#<UIButton..>, #<UIButton...>]
  def viewsWithStylename name
    r = []
    subviews.each do |view|
      if view.stylename == name
        r.push name
      end
      r += view.viewsWithStylename name
    end
    r
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
teacup-0.3.11 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.10 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.9 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.8 lib/teacup/z_core_extensions/ui_view_getters.rb
teacup-0.3.7 lib/teacup/z_core_extensions/ui_view_getters.rb