Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing an array for string options? #532

Open
greggman opened this issue Mar 30, 2023 · 1 comment
Open

Allowing an array for string options? #532

greggman opened this issue Mar 30, 2023 · 1 comment

Comments

@greggman
Copy link

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
Copy link

Sija commented Feb 17, 2024

I have the same issue/feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants