Reputation: 111
I'm extremely new to javascript and dat.gui so bear with me. I'm wondering how to create a drop down menu with a default value at the top:
so i have something like:
gui.add(text, 'language', ['english','spanish','french']);
How could I make that drop down say something like "Select Language" by default before actually selecting a value?
thanks!
Upvotes: 7
Views: 2751
Reputation: 878
After struggling a lot with a similar problem, I can tell you that I have no idea how to do specifically what you ask for with dat.GUI . However, you can select a default value like this:
let dropdown = gui.add(text, 'language', ['english','spanish','french']);
dropdown.setValue("french"); // cuz I like french better
I know this is an old question, but I hope it helps someone out there XD
Edit: you could also chain it all together :P
gui.add(text, "language", ["english", "spanish", "french"]).setValue("french");
Upvotes: 5
Reputation: 1
I did this
initialization with option 'spanish' or another valid option, if the option doesn't exist it will fail
gui.add(text, 'language', ['english','spanish','french']);
text.language = 'spanish';
updateDisplay(gui);
updateDisplay = function(gui) {
for (var i in gui.__controllers) {
gui.__controllers[i].updateDisplay();
}
for (var f in gui.__folders) {
SCENE.updateDisplay(gui.__folders[f]);
}`enter code here`
};
Upvotes: 0