RadioButtons

English

RadioButtonsは複数の候補から最大1項目を選択します。

表示例

RadioButtons on Ubuntu
Ubuntu
RadioButtons on Windows
Windows
RadioButtons on macOS
macOS

実行例

require "uing"

UIng.init

window = UIng::Window.new("RadioButtons Example", 300, 100, margined: true)
window.on_closing do
  UIng.quit
  true
end

group = UIng::Group.new("Options")

radio_buttons = UIng::RadioButtons.new(["Option 1", "Option 2", "Option 3"])
radio_buttons.selected = 0
radio_buttons.on_selected do |idx|
  window.msg_box("RadioButtons Changed", "Selected index: #{idx}")
end

group.child = radio_buttons
window.child = group
window.show

UIng.main
UIng.uninit

使い方

  • 選択位置は0始まりで、未選択時はnilです。
  • on_selectedには選択位置が渡されます。

APIリファレンス · Galleryソース