MultilineEntry
MultilineEntryは複数行のテキストを編集または表示します。
表示例
実行例
require "uing"
UIng.init
window = UIng::Window.new("MultilineEntry Example", 420, 280, margined: true)
window.on_closing do
UIng.quit
true
end
editor = UIng::MultilineEntry.new(wrapping: true)
editor.text = "Type here. Long lines wrap automatically."
editor.font_size = 18
status = UIng::Label.new("The text is editable")
editor.on_changed do
status.text = "Text changed"
end
append_button = UIng::Button.new("Append line")
append_button.on_clicked do
editor.append("\nAppended text")
end
read_only = UIng::Checkbox.new("Read only")
read_only.on_toggled do |checked|
editor.read_only = checked
status.text = checked ? "The text is read only" : "The text is editable"
end
font_size = UIng::Spinbox.new(8, 72, value: 18)
font_size.on_changed do |size|
editor.font_size = size
end
controls = UIng::Box.new(:horizontal, padded: true)
controls.append(append_button)
controls.append(read_only)
controls.append(UIng::Label.new("Font size"))
controls.append(font_size)
box = UIng::Box.new(:vertical, padded: true)
box.append(editor, stretchy: true)
box.append(status)
box.append(controls)
window.child = box
window.show
UIng.main
UIng.uninit
使い方
- 折返しの有無は作成時に選び、後からは変更できません。
- 逐次出力には
append、ログ表示にはread_onlyが便利です。


