Inspector and Enums

I have a canvas subclass to which I have added a property called Orientation. I have checked that class in Inspector Behavior and added an enumeration (Northeast = 0, Southeast = 1, …). However, I don’t seem to be able to refer to the enumeration constants in code. I’d really like to use a statement like “If Orientation = Northeast Then” but it appears that I can’t. Am I missing something, or are custom enumerations only half usable.


Check the docs:

[quote]If it is in a class then you have to use the full notation irrespective of the scope:


The problem is that a custom enumeration added in Inspector Behavior does not seem to have a name by which you can refer to it.

I usually create constants within my class for these values and name the enumerated inspector values the same (or at least similar). That’ll give you the functionality you want.

So, let’s say you have a border property for a class with the name “MyControl” with possible values of “BorderNone”, “BorderSingle”, and “BorderWide”. You’d add those as constants with values 0, 1, and 2 respectively and set them to public. Now, throughout your project, you can use “MyControl.BorderNone” to retrieve the value of that constant.

That would work, but it’s not very good software engineering .

IIRC correctly Enums in the “inspector” existed before enums in the language and so unfortunately developed independently.

You should be able to use ‘real’ Enums.

If an attribute is declared as a enum, it does not appear in Inspector Behavior.


Seems I’m having the same issue.

  1. I don’t seem to be able to refer to enums declared in Inspector Behaviour, and conversely
  2. enums created in the IDE can’t be referred to in Inspector Behaviour.

It’s like the 2 types of enum are mutually exclusive.

In my case, I have a container control that contains a large array of buttons that can be chosen by name in the program to form different button panels. Up until now I have given each button a string property to define its name throughout the program. I wanted to turn this into a better defined enum to make referencing easier and less error prone.

If I define an enumeration within the containerControl, I can make it the class of the buttonName property, but I can’t find a way of viewing this property within the Inspector Behaviour.
If I try the other way, and define the enum values of an integer property within Inspector Behaviour as custom values, then I can’t find a way of referring to those values elsewhere in the program.

Am I missing something?


I just came across to this problem. How can I add a Property that points to Enumeration in Inspector Behavior? They don’t appear on the list.

You don’t
You provide the enumerated values right there along with any string tags (labels) they’ll show up with

So, I can’t use enumeration I have added to a ContainerControl?



Just define them to have the same integer values and it should all work fine