class Iup::MenuItem
A menu item is 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.
Attributes¶ ↑
- autotoggle
-
Sets auto toggle for item when menu activated, values 'yes' / 'no'.
- hidemark
-
If set, hides the mark. Values 'yes' / 'no'.
- image
-
Image
used when check enabled. - impress
-
Image
used when check disabled. - title
-
Label
to display on menu item. - titleimage
-
Image
to show on menu item. - value
-
Determines if check is enabled or not, values 'off' / 'on'.
- wid
-
read-only Native widget identifier.
Public Class Methods
new(title, callback = nil, &block)
click to toggle source
Creates an instance of MenuItem
.
- title
-
Label
to display - callback
-
Optional action to call when
MenuItem
is clicked. - block
-
Optional block to set up menu item's attributes.
# File lib/wrapped/menuitem.rb, line 25 def initialize title, callback = nil, &block @handle = IupLib.IupItem title, nil action callback unless callback.nil? # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end
Public Instance Methods
action(callback)
click to toggle source
Action generated when the element is activated.
# File lib/wrapped/menuitem.rb, line 59 def action callback unless callback.arity.zero? raise ArgumentError, 'action callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'ACTION', :plain end
highlight_cb(callback)
click to toggle source
Action generated when the item is highlighted.
# File lib/wrapped/menuitem.rb, line 70 def highlight_cb callback unless callback.arity.zero? raise ArgumentError, 'highlight_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'HIGHLIGHT_CB', :plain end