Combobox

日本語

Combobox lets the user choose one item from a fixed list.

Appearance

Combobox on Ubuntu
Ubuntu
Combobox on Windows
Windows
Combobox on macOS
macOS

Runnable example

require "uing"

UIng.init

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

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

window.child = combobox
window.show

UIng.main
UIng.uninit

Usage notes

  • Use selected and selected= with zero-based indices.
  • Items can be appended, inserted, deleted, or cleared.

API reference · Gallery source