Skip to content
New issue

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

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

Already on GitHub? # to your account

Custom enums: Allow of multiple values enhancement #3458

Open
ChristianPervoelz opened this issue Aug 22, 2022 · 2 comments
Open

Custom enums: Allow of multiple values enhancement #3458

ChristianPervoelz opened this issue Aug 22, 2022 · 2 comments
Labels
feature It's a feature, not a bug.

Comments

@ChristianPervoelz
Copy link
Contributor

Custom enums are a great and really easy way to define custom properties and by that create new templates/classes in a quick manner.
But in some cases they might become confusing or may lead to errors. :(

In one of my projects I have defined an enum named Fruits with (just an excerpt) values: apple, banana, peach and so on.

Now I have two custom classes: SingleFruit (represents a single fruit) and PileOfFruits (represents many fruits). Both have Fruits as member.

The problem is now, that I have to check Allow mutiple values (flags) in the enum, as else I cannot easily have multiple entries for the PileOfFruits class.
On the other hand, this allows the SingleFruit class to have multiple values too, but that one should have one value at a time only (as the name says).

Idea
It would be very great to have an additional option in custom types editor, that allows to set an enum member of a class to be either multi-value or single-value.

Alternatives
There is a couple of alternatives, of course:

  • create a second enum with the same values (and different name), not allowing multi selection (could become quite messy, easily)
  • don't use the enum at all (would be a pitty)
  • being careful, what is selected for SingleFruit ;)
@ChristianPervoelz ChristianPervoelz added the feature It's a feature, not a bug. label Aug 22, 2022
@bjorn
Copy link
Member

bjorn commented Aug 22, 2022

I feel like there is another solution, which would be to add support for array properties (#1493). Then your PileOfFruits could have an array of Fruit member. A possible downside is that it can then contain the same fruit multiple times, though that could also be a positive.

@ChristianPervoelz
Copy link
Contributor Author

Agreed. That sounds like a very good solution.
And yes, multiple entries of the same type would be good for a pile of fruits,, as only one of each type doesn't leave much choices, if one does not like bananas, but apples only. ;)

So I think, it would be great to have arrays, may with the option to prevent multiple entries of the same value (not sure whether that's really meaningful).

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

2 participants