Here’s quick test module:
module Testing
extend self
@dialog = nil if !defined?(@dialog)
def go
if @dialog.nil?
create_dialog()
elsif !@dialog.visible?
attach_callbacks()
@dialog.show
else
front()
end
end
def behind
Sketchup.focus
end
def front
@dialog.bring_to_front
end
private
def attach_callbacks
@dialog.add_action_callback("Dummy") {|_, params|
puts "Dummny callback"
}
# ... more callbacks ...
end
def create_dialog
@dialog = UI::HtmlDialog.new(
dialog_title: "Dialog Example",
preferences_key: "Dialog Testing",
scrollable: true,
resizable: true,
width: 600,
height: 400,
left: 100,
top: 100,
min_width: 50,
min_height: 50,
max_width: 1000,
max_height: 1000,
style: UI::HtmlDialog::STYLE_WINDOW
)
@dialog.set_url("http://www.sketchup.com")
attach_callbacks()
@dialog.show
end
end
(… scroll to see all code …)