Class: OperaWatir::QuickMenu

Inherits:
QuickWidget show all
Defined in:
lib/operawatir/quickwidgets/quick_menu.rb

Overview

??

Constant Summary

Constants inherited from QuickWidget

OperaWatir::QuickWidget::ConditionTimeout

Instance Method Summary collapse

Methods inherited from QuickWidget

#click_with_condition, #double_click_with_condition, #enabled?, #focus_with_click, #focus_with_hover, #has_ui_string?, #middle_click_with_condition, #open_menu_with_rightclick, #open_window_with_hover, #parent_name, #position, #quick_tabs, #quick_widgets, #right_click_with_condition, #text, #type, #value, #verify_includes_text, #verify_text, #visible?, #widget_info_string

Methods included from DesktopContainer

#quick_addressfield, #quick_button, #quick_checkbox, #quick_dialogtab, #quick_dropdown, #quick_dropdownitem, #quick_editfield, #quick_find, #quick_griditem, #quick_gridlayout, #quick_label, #quick_menu, #quick_menuitem, #quick_radiobutton, #quick_searchfield, #quick_tab, #quick_thumbnail, #quick_toolbar, #quick_treeitem, #quick_treeview, #quick_window

Instance Method Details

#exist?Boolean Also known as: exists?

Checks whether a widget exists or not

Returns:

  • (Boolean)

    true if the widget exists otherwise false



125
126
127
128
129
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 125

def exist?
  !!element
  rescue Exceptions::UnknownObjectException
    false
end

#heightObject

Returns height of widget.

Returns:

  • height of widget



76
77
78
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 76

def height
  element.getRect().height
end

#nameObject

Returns the name of the menu (as found in standard_menu.ini).

Examples:

browser.quick_menu(:name, "Browser Button Menu Bar").name.should == "Browser Button Menu Bar"

Returns:

  • the name of the menu (as found in standard_menu.ini)



32
33
34
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 32

def name
  element.getName
end

#parentmenu?Boolean

Returns true if this menu has one or more submenus.

Examples:

menu.should be_parentmenu

Returns:

  • (Boolean)

    true if this menu has one or more submenus



97
98
99
100
101
102
103
104
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 97

def parentmenu?
  element.getItemList().each do |item|
    if item.hasSubMenu()
      return true
    end
  end
  false
end

#quick_menuitemsObject

@example:

menu.menuitems.select { |item| item.menu != menu.name }.should be_empty
menu.menuitems.each { | item | puts item.name }

Returns:

  • array of all menuitems in this menu



114
115
116
117
118
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 114

def quick_menuitems
  element.getItemList().map do |java_item|
    QuickMenuItem.new(self,java_item)
  end
end

#to_sObject

Returns string representation of menu.

Returns:

  • string representation of menu



59
60
61
62
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 59

def to_s
  window = window_id > 0 ? "window_id #{window_id}" : ""
  "QUICKMENU #{name} #{window}" # TODO: Add rect
end

#widthObject

Returns width of widget.

Returns:

  • width of widget



68
69
70
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 68

def width
  element.getRect().width
end

#window_idObject

Note: This only makes sense for the menubars (and not on mac where there is

only one menubar)

Note: This makes it possible to distinguish between menubars in different

main windows

@example:

browser.quick_menu(:name, "Main Menu").window_id
browser.quick_window(:id, <id>).quick_menu(:name, "Browser File Menu")...

Returns:

  • the window_id of the window the menu is attached to



51
52
53
# File 'lib/operawatir/quickwidgets/quick_menu.rb', line 51

def window_id
  element.getParentWindowId()
end