I checked Ruby API. The HtmlDialog has set_url method, no get_url. I want to save the current url when the dialog is closed. How can I get the current url of a dialog?
It seems no way to get url?
I checked Ruby API. The HtmlDialog has set_url method, no get_url. I want to save the current url when the dialog is closed. How can I get the current url of a dialog?
It seems no way to get url?
Sure there is a way, e.g.:
dialog = UI::HtmlDialog.new(
dialog_title: "Dialog Example",
preferences_key: "my_name_my_extension_my_dialog",
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_DIALOG
)
dialog.set_url("https://www.sketchup.com")
dialog.add_action_callback("last_url") { |action_context, lasturl|
puts "Dialog closed at url: #{lasturl} "
}
dialog.set_can_close {
js_command = 'sketchup.last_url(window.location.href);'
dialog.execute_script(js_command)
true
}
dialog.show