Module: WindowEnumerable

Includes:
Enumerable
Defined in:
lib/xrc_pepper.rb

Overview

Access to Window children Injected into Wx::Window

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

access children window by name directly as attribute reader



31
32
33
34
35
36
37
# File 'lib/xrc_pepper.rb', line 31

def method_missing(name, *args)
  if [:ok, :cancel, :yes, :no].include?(name)
    win = Wx::Window.find_window_by_name("wxID_#{name.to_s.upcase}", self)
    return win if win
  end
  Wx::Window.find_window_by_name(name.to_s, self) || super
end

Instance Method Details

#eachObject

ruby way to iterate over children



21
22
23
# File 'lib/xrc_pepper.rb', line 21

def each
  get_children.each {|item| yield item}
end

#each_descendant(&block) ⇒ Object

iterate over children and all descendant



26
27
28
# File 'lib/xrc_pepper.rb', line 26

def each_descendant(&block)
  each {|item| block.call(item); item.each_descendant(block) }
end