123456789_123456789_123456789_123456789_123456789_

Class: Sketchup::Menu

Relationships
Inherits: Object

Overview

An interface to a menu.

Version:

  • SketchUp 6.0

Instance Method Summary

Instance Method Details

#add_item(title) { ... } ⇒ 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(title) { ... } ⇒ Integer

    Parameters:

    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

    Parameters:

    Returns:

    • (Integer)

      A unique integer id for the added menu item.

Version:

  • SketchUp 6.0

#add_separatornil

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

Examples:

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

Version:

  • SketchUp 6.0

#add_submenu(title) ⇒ Menu

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!")
}

Parameters:

  • title (String)

    The title of the sub menu.

Returns:

  • (Menu)

    a Menu object

Version:

  • SketchUp 6.0

#set_validation_proc(item) { ... }

The #set_validation_proc method is used to specify 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
}

Parameters:

  • item (Integer)

    The numerical identifier for the menu item.

Yields:

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

Version:

  • SketchUp 6.0