Class: Sketchup::Menu

Inherits:
Object
  • Object
show all

Overview

An interface to a menu.

Version:

  • SketchUp 6.0

Instance Method Summary # collapse

Instance Method Details

#add_item(menu) { ... } ⇒ Integer #add_item(command) ⇒ Integer

The #add_item method is used to add a menu item to the specified menu.

This method takes a block that defines the action to perform when the menu item is selected.

The item id that is returned can be used when adding an optional validation procedure for the menu item.

Examples:

menu = UI.menu('Plugins')
menu.add_item("Test") { puts 'Hello World' }

Overloads:

  • #add_item(menu) { ... } ⇒ Integer

    Returns A unique integer id for the added menu item.

    Parameters:

    • menu (String)

      The name of the menu to add.

    Yields:

    • A block that will be invoked when the menu item is selected.

    Returns:

    • (Integer)

      A unique integer id for the added menu item.

  • #add_item(command) ⇒ Integer

    Returns A unique integer id for the added menu item.

    Parameters:

    Returns:

    • (Integer)

      A unique integer id for the added menu item.

Version:

  • SketchUp 6.0

#add_separatorObject

The add_separator method is used to add a menu separator to a menu.

Examples:

plugins_menu = UI.menu("Plugins")
plugins_menu.add_separator

Returns:

  • nil

Version:

  • SketchUp 6.0

#add_submenu(title) ⇒ Object

The add_submenu method is used to add a sub-menu to a menu.

Examples:

plugins_menu = UI.menu("Plugins")
submenu = plugins_menu.add_submenu("Test")
submenu.add_item("Hello World") {
  UI.messagebox("Hi there!")
}

Returns submenu - a Menu object

Parameters:

  • title (String)

    The title of the sub menu.

Returns:

  • submenu - a Menu object

Version:

  • SketchUp 6.0

#set_validation_proc(menu) { ... } ⇒ Object

The set_validation_proc method is used to identify the menu validation procedure. Your procedure should return either MF_ENABLED, MF_DISABLED, MF_CHECKED, MF_UNCHECKED, or MF_GRAYED.

Examples:

plugins_menu = UI.menu("Plugins")
item = plugins_menu.add_item("Test") { UI.messagebox "My Test Item"}
status = plugins_menu.set_validation_proc(item)  {
  if Sketchup.is_pro?
    MF_ENABLED
  else
    MF_GRAYED
  end
}

Returns item_id - a unique numerical item id for the menu

Parameters:

  • menu

    A string name of the menu to add.

Yields:

  • A method that will be invoked when the menu item is selected.

Returns:

  • item_id - a unique numerical item id for the menu

Version:

  • SketchUp 6.0