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.

Methods

build   item   menu   new  

Attributes

menu_bar  [R] 

Public Class methods

[Source]

    # 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

This builder must be provided with a context. All menu item actions will be invoked on the context.

[Source]

    # File lib/limelight/dsl/menu_bar.rb, line 46
46:       def initialize(context)
47:         @context = context
48:         @menu_bar = javax.swing.JMenuBar.new
49:       end

Public Instance methods

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.

[Source]

    # 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

Creates a new menu with the provided name

[Source]

    # File lib/limelight/dsl/menu_bar.rb, line 53
53:       def menu(name)
54:         @menu = javax.swing.JMenu.new(name)
55:         @menu_bar.add(@menu)
56:         yield
57:       end

[Validate]