Hello,
In the following sample, I would simply like to list the class of each entity. I think, my code to add the list item is incorrect and am wondering if someone can help.
dialog = UI::HtmlDialog.new(
{
:dialog_title => “Dialog Example”,
:preferences_key => “com.sample.plugin”,
: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
})
html= ’
<!DOCTYPE html>
<html>
<head><title>My First Test</title></head>
<script type="text/javascript">
function test(){
sketchup.say(“Hello World”, “value 2”);
}
function test1(){
sketchup.printclass();
}
</script>
<body>
<b id="id">Hello world!</b>
<br />
<b id="test"> My Test </b>
<p>Click to test </p>
<p><input type="button" onclick=test1() value="Do Something" /></p>
<div id="test2">
</div>
</body>
</html> '
dialog.set_html(html)
dialog.show
dialog.add_action_callback(“say”) { |action_context, param1, param2|
text= “JavaScript said #{param1} and #{param2}”
UI.messagebox(text, MB_YESNO)
}
dialog.add_action_callback(“printclass”){
js_command = "document.getElementById('test2').innerHTML = '<ul id=ti>' + '</ul>'" dialog.execute_script(js_command)
Sketchup.active_model.entities.each do |e| js_command = "document.getElementById('ti').innerHTML+= '<li>' + e.class.to_s + '</li>'" dialog.execute_script(js_command)
end
}
Yogesh
HtmlDialog2.rb (1.3 KB)