Module: WidgetWrapper::Menus::MenuBar

Defined in:
lib/wx_wrapper/menu.rb

Overview

Menu bar syntax (This code follows after a frame block):

menu_bar.menu "&File" do |item|
  item.add :new
  item.add :open
  item.separator
  item.add :save
  item.separator
  item.add :quit
end

menu_bar.menu "&Edit" do |item|
  item.add :undo
  item.add :redo
end

The & in the menu title (ie &File) is used underlined and used as a shortcut for referencing alt command navigation for windows. You can move the ampersand in front of a different letter if you would like another letter to be the shortcut for alt keys. (As of yet, I don’t know how this works in OS X if it has any effect at all).

Instance Method Summary collapse

Instance Method Details

Creates a menu inside of the menu bar.

menu_bar.menu "&File" do |item|
  item.add :new
end


62
63
64
65
66
67
68
69
70
# File 'lib/wx_wrapper/menu.rb', line 62

def menu(title, options = {})
  new_menu = Wx::Menu.new
  
  if block_given?
    yield(new_menu)
  end
  
  append(new_menu, title)
end

Gets a list of menus in the menu bar



53
54
55
# File 'lib/wx_wrapper/menu.rb', line 53

def menus
  (0..(get_menu_count-1)).collect {|menu_id| get_menu(menu_id)}
end