Class: Iup::Menu

Inherits:
Widget show all
Defined in:
lib/wrapped/menu.rb

Overview

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.

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods inherited from Widget

#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb

Methods included from AttributeBuilders

#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly

Methods included from CallbackSetter

#define_callback

Constructor Details

#initialize(*widgets, &block) ⇒ Menu

Creates instance of a menu.

*widgets

one or more menu items, sub menus or separators.

block

optional block to set up menu’s attributes.



38
39
40
41
42
43
# 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