@unknownuser said:
I meant if you could show us how you have connected html and Ruby. How you pass results back to Ruby.
Tomasz
Ah. Well you don't need dhtml suite for that.
Here is the ruby code that launches a very simple html dialog:
def showVerySimple()
#create
dlg = UI;;WebDialog.new("VerySimple", true,"verysimple", 300, 300, 100, 50, true)
fn= File.dirname(__FILE__)+'/verysimple.html'
dlg.set_file fn
dlg.show {} #show it
#create a callback for anytime a value changes in the dialog.
dlg.add_action_callback("ValueChanged") {|d,p|
puts p
}
end
The "add_action_callback" code at the end allows the dialog to communicate with sketchup. The "puts p" will print out the name and value of a control that changed.
Here is the HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<title>Webdialog UI </title>
</HEAD>
<body>
<div>
<font color="blue">Checkboxes</font><br>
<input type="checkbox" name="check-one" onClick="tellSketchup(this.name,this.checked)">One</input>
<input type="checkbox" name="check-two" onClick="tellSketchup(this.name,this.checked)">Two<br></input>
<input type="checkbox" name="check-three" onClick="tellSketchup(this.name,this.checked)">Three</input>
<br>
<font color="blue">Radio</font><br>
<INPUT type=radio name="radio" value="radio-a" onClick="tellSketchup(this.value,this.checked)">Aye
<INPUT type=radio name="radio" value="radio-b" onClick="tellSketchup(this.value,this.checked)">Bee
<INPUT type=radio name="radio" value="radio-c" onClick="tellSketchup(this.value,this.checked)">See<br>
</div>
<script type="text/javascript">
function tellSketchup(name,value)
{
//this non-intuitive command will call the sketchup callback "ValueChanged"
//with the name and value of the control that changed
window.location='skp;ValueChanged@'+name +"="+ value;
}
</script>
</body>
</HTML>
The HTML creates three checkboxes and three radio buttons. Anytime a user clicks on a control (ie. changes it) the "onClick" code is called. In this case it calls a javascript function called "tellSketchup". That function simply passes the info to sketchup in the form of a string like "check-one=true".
Thats it!
Chris