class Iup::Button

A button can display some text, an image, or both. When clicked, a specified action function is called. The action should return Iup::DEFAULT, or, if the button should exit the application, Iup::CLOSE.

(1) A button with some text and an action

Iup::Button.new('click me', ->{
  puts 'clicked'
  Iup::DEFAULT
})

(2) A button with an image stored in img and action specified by a separate method; some padding around the image within the button.

def click_fn
  puts 'clicked'
  Iup::DEFAULT
end

Iup:Button.new('', ->{ click_fn }) do |b|
  b.image = img
  b.padding = '50x20'
end

(3) A button with text and image, image placed above text. The text contains an & before the “x”, so the action can be triggered using ALT+x, and closes the application.

Iup::Button.new('e&xit', ->{ puts 'exit'; Iup::CLOSE }) do |b|
  b.image = img
  b.imageposition = 'top'
end