Domanda

dat.gui.js

I am trying to use the text input in DAT.GUI.js, when I click the input box, the text input box should be clear if there has a default value. After finished, it will come out a confirm box(Message Box) to inform the user their input message.

Right now, My code is like this, but if I choose the Cancel it can not clear the input text. If the default text is not empty, I still need to delete the world use Backspace And also I do not want the default name "Close Controls", can I delete this?

var params = {
     text:""
};
var gui = new dat.GUI();
    gui.add(params, 'text').name('ID:').onFinishChange(function (value) {

        if (confirm('Is" '+ value +  ' "id?') === true) {
            workerId = value;
        } else {
            value = "";// I also tried params.text = ""; but still can not clear the input box
        }
    });

Any suggestion is appreciated, thanks!

Solved

gui.add(params, 'text').name('Your Worker ID:').listen().onFinishChange(function (value) {
    if (confirm('Is" '+ value +  ' "your worker id?') === true) {
        workerId = value;
    } else {
        params.text="";
    }
});
È stato utile?

Soluzione

gui.add(params, 'text').name('Your Worker ID:').listen().onFinishChange(function (value) {
    if (confirm('Is" '+ value +  ' "your worker id?') === true) {
        workerId = value;
    } else {
        params.text="";
    }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top