FWIW, this is how I did it (and my initial post was looking for nicer way)
In the constructor
add_action_callback("onload") do |context|
execute_script("set_value(#{value.inspect})")
end
And in the html
<script type="text/javascript">
function init() {
sketchup.onload()
}
function set_value(value) {
// do something with the value
}
</script>
...
<body onload="init()">
Too much boilerplate for something that I expect is very common: passing constructor arguments into the dialog. Would have been nice if there was a way to add values to the sketchup
object in JS. Something like set_value(some_name, value)
that would make sketchup.some_name
have value
. Or, if that is not possible, have show
accept a block as was in WebDialog
And while we’re on the subject of improving HtmlDialog, it would be nice to have a predefined css to get a standard look and feel (beyond raw html), and maybe jquery integration built in instead of needing to pull it into the plugin or rely on external (network) URLs.