I am using dat.gui to provide an interface for an application to control the scene similar to the following example:
http://workshop.chromeexperiments.com/examples/gui/#1--Basic-Usage
Problem:
I need to add an action to the checkbox and another action to the text (display Outline) next to the checkbox.
For example, there is a text in the scene. When I click the checkbox, it must show/Hide the text and when I click the "displayOutline" it must zoom in to the text. However, in the above link, when you click the text or the checkbox, one action is happened. I cannot add different actions to the text and checkbox.
Code:
var folder1 = gui.addFolder('Basement');
folder1.add( parameters, 'visible' ).name('Lot 1');
var spans = document.getElementsByTagName('span');
for (var i = 0, l = spans.length; i < l; i++){
var text = spans[i].textContent || spans[i].innerText;
if (text == "displayOutline")
{
var checkbox = spans[i].nextSibling.firstChild;
checkbox.addEventListener('click', function(event){
// Do something with the checkbox
alert("checked");
});
}
}
Question:
How can I add different actions to the checkbox and the text next to the checkbox?
Thank you for your help.