ModraUp Ruby API Documentation Ruby API Reference

Class: ModraUp::Menu

Inherits:
Object
  • Object
show all

Overview

Top-level menus or submenus. Obtain them using UI.menu or #add_submenu.

Examples:

menu = UI.menu("Plugins")
menu.add_item("Beep") { UI.beep }

Instance Method Summary # collapse

Instance Method Details

menu.add_item(title) { } ⇒ Integermenu.add_item(command) ⇒ Integer

Add an item. The string title must be in a block; alternatively, you can pass UI::Command.

Parameters:

  • title (String, UI::Command)

Returns:

Raises:

  • [ArgumentError] String title must have a block

Examples:

UI.menu("Plugins").add_item("Beep") { UI.beep }

menu.add_separator ⇒ true

Add a separator to the menu.

Returns:

  • (true)

Examples:

UI.menu("Plugins").add_separator

menu.add_submenu(title) ⇒ ModraUp::Menu

Add a sub-menu and return it. The top bar is available in both the context menu as defined by UI.add_context_menu_handler and the right-click menu.

Parameters:

  • title (String)

Returns:

  • (ModraUp::Menu)

Examples:

UI.menu("Plugins").add_submenu("Demo").add_item("Beep") { UI.beep }

Right-click in the viewport

UI.add_context_menu_handler do |menu|
  menu.add_submenu("Dynamic Components").add_item("Redraw") { UI.beep }
end

menu.set_validation_proc(item_id) { } ⇒ true

Set a validation block for the id returned by #add_item, which should return values like MF_ENABLED.

Parameters:

  • item_id (Integer)

Returns:

  • (true)

Yields:

  • @yieldreturn [Integer]

Raises:

  • [ArgumentError] No block provided

Examples:

menu = UI.menu("Plugins")
id = menu.add_item("Beep") { UI.beep }
menu.set_validation_proc(id) { MF_ENABLED }