Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Dropdown value dat.gui

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!

like image 861
DSquad Avatar asked Jun 24 '16 17:06

DSquad


1 Answers

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”);
like image 69
Jaacko Torus Avatar answered Sep 16 '22 17:09

Jaacko Torus