Class: Nobbie::Wx::ElementPathBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/nobbie/wx/impl/element/element_path_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ElementPathBuilder

Returns a new instance of ElementPathBuilder.



12
13
14
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 12

def initialize(name)
  @name = name
end

Instance Method Details

#find_componentObject

Finds the component specified in the path. This implementation is about as dumb as its gets, but does handle named components and menus.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 18

def find_component
  #todo: make me properly navigate component tree
  #todo: I should blow up if multiple windows with the same name are found ....

  #todo: shouldn't need to pass top_window here ... nil should search all
  component = Window.find_window_by_name(@name, TOP_WINDOW)
  return component unless component.nil?

  menu_bar = TOP_WINDOW.get_menu_bar
  unless menu_bar.nil?
    component = menu_bar.get_menu(menu_bar.find_menu(@name))
  end

  #todo: pull this up ...
  Kernel.raise(ComponentNotFoundException, "cannot find component with name: #{to_s}") if component.nil?

  component
end

#to_sObject



37
38
39
# File 'lib/nobbie/wx/impl/element/element_path_builder.rb', line 37

def to_s
  "'#{@name}'"
end