class Iup::MenuItem
A menu item is the interactive part of a menu, and acts like a button. The menu item can display a simple text label, an image, or act as a check box. When placed within a menu with the radio flag set, several menu items can act as a radio button group within a menu.
Example
(1) Item with text and action.
item_exit = Iup::MenuItem.new('Exit', ->{ Iup::CLOSE })
(2) Checkbox
show_toolbar = Iup::MenuItem.new('Show toolbar') do |i| i.value = :off # assign a value to make menu item a checkbox i.autotoggle = :yes # allow value to change when menu item clicked end
Placing a set of checkbox menuitems into a Menu with radio set turns the menuitems into a linked radio group.
Attributes
Sets auto toggle for item when menu activated, values โyesโ / โnoโ. i.e. the menu itemโs check status is inverted when clicked.
If set, hides the mark. Values โyesโ / โnoโ.
Image name or instance to show on menu when check enabled. This can use an actual image object, or the name of an image from IupImageLib.
Image name or instance to show on menu when check disabled. This can use an actual image object, or the name of an image from IupImageLib.
Title text to display on menu item.
Image name or instance to show on menu item. This can use an actual image object, or the name of an image from IupImageLib.
Determines if check is enabled or not, values โoffโ / โonโ.
Native widget identifier.
Public Class Methods
Source
# File lib/wrapped/menuitem.rb, line 34 def initialize(title, callback = nil) @handle = IupLib.IupItem(title, nil) self.action = callback unless callback.nil? # run any provided block on instance, to set up further attributes yield self if block_given? end
Creates a new instance. If a block is given, the new instance is yielded to it.
-
title- text to display -
callback- Optional action to call when clicked with left button.
Callbacks
Attributes
Callback called when the element is activated. Callback must respond to call and take no arguments.
Callback called when the item is highlighted. Callback must respond to call and take no arguments.