This suffices for a simple dialog. If your requirements grow, you would save the html
string into a file and load it with set_file
, then move the JavaScript call from inline into a <script>
block or a separate file (same for styles), etc.
See here for the documentation.
def show_my_messagebox(message, title)
properties = {
:dialog_title => title,
:scrollable => false,
:width => 300,
:height => 350
}
html = <<-HTML
<html>
<body>
<img src="https://www.sketchup.com/themes/sketchup_www_terra/images/SU_FullColor.png" width="100%" />
<h1>#{title}</h1>
<p>#{message}</p>
<div style="text-align: center">
<button onclick="window.sketchup.close()">Close</button>
</div>
</body>
</html>
HTML
dialog = UI::HtmlDialog.new(properties)
dialog.set_html(html)
dialog.add_action_callback('close') { |action_context|
dialog.close
}
dialog.center
dialog.show_modal
end
show_my_messagebox("You are using SketchUp #{Sketchup.version} with Ruby #{RUBY_VERSION}", "Hello SketchUpper!")