class Iup::Menu

A Menu is a collection of menu items, submenus, and separators.

For example, the following menu has the items: Open, Save, —-, Undo, Exit The Undo item is greyed out as it is inactive, and the Exit item, when clicked, will close the dialog. Notice how the File menu, which contains these items, is a submenu of the main menu.

mainloop do
  item_open = MenuItem.new 'Open'
  item_save = MenuItem.new 'Save' 
  item_undo = MenuItem.new 'Undo' do
    active 'NO'
  end
  item_exit = MenuItem.new 'Exit', ->{ CLOSE } 
  file_menu = Menu.new item_open, item_save, Separator.new, item_undo, item_exit
  menu = Menu.new SubMenu.new('File', file_menu)

  Dialog.new Canvas.new do
    menu menu
    size '200x100'
    title 'Menu Example'
  end.show
end

Attributes

radio

If set, makes children act as a radio group. Values 'yes' / 'no'.

wid

read-only Native widget identifier.

Public Class Methods

new(*widgets, &block) click to toggle source

Creates instance of a menu.

*widgets

one or more menu items, sub menus or separators.

block

optional block to set up menu's attributes.

# File lib/wrapped/menu.rb, line 38
def initialize *widgets, &block
  @handle = IupLib.IupMenu *widget_list(widgets)

  # run any provided block on instance, to set up further attributes
  self.instance_eval &block if block_given?
end