Tab

English

Tabはコントロールを名前付きの複数ページに整理します。

表示例

Tab on Ubuntu
Ubuntu
Tab on Windows
Windows
Tab on macOS
macOS

実行例

require "uing"

UIng.init

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

tab = UIng::Tab.new
tab.append("Tab 1", UIng::Label.new("This is Tab 1"))
tab.append("Tab 2", UIng::Label.new("This is Tab 2"))
tab.on_selected do |idx|
  window.msg_box("Tab Changed", "Selected index: #{idx}")
end

window.child = tab
window.show

UIng.main
UIng.uninit

使い方

appendまたはinsert_atでページを追加します。各ページが持つ子は1つで、複数のコントロールはBoxやFormにまとめます。選択中のページだけが表示されます。

selectedが0ならGeneralのBoxを、1ならDetailsのFormを表示する

tab = UIng::Tab.new
tab.append("General", UIng::Box.new(:vertical), margined: true)
tab.append("Details", UIng::Form.new, margined: true)
tab.selected = 1

selectedは0始まりのページ番号です。変更はon_selectedで受け取ります。余白はページごとにmargined: trueで指定し、追加後はset_margined(index, true)で変更できます。

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