| Class | Limelight::DSL::MenuBar |
| In: |
lib/limelight/dsl/menu_bar.rb
|
| Parent: | Object |
A class used to build menu bars using a DSL.
MenuBar.build(self) do
menu("File") do
item("Open", :open_chosen_scene)
item("Refresh", :reload)
end
end
This example created one menu named ‘File’ with two menu items: ‘Open’ and ‘Refresh’. The seconds parameter of the menu items is the symbol of a method on the context that will be invoked when the menu item is selected.
| menu_bar | [R] |
# File lib/limelight/dsl/menu_bar.rb, line 36
36: def self.build(context, &prop)
37: builder = self.new(context)
38: builder.instance_eval(&prop)
39: return builder.menu_bar
40: end
Created a new menu item with the provided name. The symbols paramter is the name of a method on the context that will be invoked when the item is selected.
# File lib/limelight/dsl/menu_bar.rb, line 62
62: def item(name, symbol)
63: menu_item = javax.swing.JMenuItem.new(name)
64: @menu.add(menu_item)
65: menu_item.addActionListener(AnonymousActionListener.new(@context, symbol))
66: end