cocopon / tweakpane

:control_knobs: Compact GUI for fine-tuning parameters and monitoring value changes
https://tweakpane.github.io/docs/
MIT License
3.57k stars 90 forks source link

Allowing an array for string options? #532

Open greggman opened 1 year ago

greggman commented 1 year ago

I'm new to tweakpane so forgive me if this is already covered.

I wanted to make a simple dropdown and wanted to do is give a list of strings

const settings = {
  fruit: 'banana',
};

const pane = new Pane();

pane.addInput(settings, 'fruit', {
  options: ['apple', 'banana', 'durian', 'grape', 'jackfruit', 'kumquat', 'lychee'],
});

But, AFAICT I have to double all the strings in an object

pane.addInput(settings, 'fruit', {
  options: {
    'apple': 'apple',
    'banana': 'banana',
    'durian': 'durian', 
    'grape': 'grape',
    'jackfruit': 'jackfruit',
    'kumquat': 'kumquat',
    'lychee': 'lychee',
  },
});

I get that could write a tiny function to generate the object from array but it seems like it would be a common use case to want to just provide a list of strings have them map to themselves.

Have you considered allowing options to be an array of values?

Sija commented 7 months ago

I have the same issue/feature request.