The Inspector Behavior is a feature that you were probably not aware of at first glance when using the Xojo IDE. It is tightly related to the Inspector Panel you are already using for adjusting all the control settings and other classes instances properties.
For example, via the use of the Inspector we can assign the Picture we want to use as the Backdrop for a Canvas control, the default items shown by a PopupMenu instance, or the initial settings for any other control, as the size, initial text, color, etc. That is, we can define the behavior for any object through its properties.
Wouldn’t it be great to have that same access via the Inspector for your own classes? It would be simple to define the initial settings for your instances instead of putting the related code in the Open Event Handler. Well it is in fact, possible for you to decide what properties can be settable via the Inspector and even provide their default values and instruct an enumerator list for those properties of numerical type. It’s a nice touch if you are designing classes for your own use but also those you expect (and hope!) will be used by other Xojo developers!
In fact, through the Inspector Behavior feature you can further decide to disable those properties that are shown by default in the Xojo Frameworks. Why you would like to do that? Maybe to avoid problems or limit the things that others developers of the project can modify by default from the IDE (or consumers for your classes).
Accessing the Inspector Behavior
To do this, choose the class definition from the Navigator and then select Inspector Behavior from the contextual menu:
Using the Inspector Behaviour Features
This takes you to the window showing all the available properties for the selected class, including those inherited from their class hierarchy and those specifically defined by you. This is, in fact, the window where we can enable the checkbox for the properties we want to be shown in the Inspector and even create new headers in order to group these properties by category. Obviously, we can also disable the checkboxes associated to the Properties we don’t want to be available from the Inspector.
As you can see in the screenshot, the example shows a very basic class that has four defined properties whose types are Color, Text and Integer.
Once they are enabled in the Inspector Behavior window, these will be shown in the Inspector, so it is easier for the class consumers to define the used colors and other initial attributes from the IDE.
Javier Rodriguez has been the Xojo Spanish Evangelist since 2008, he’s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of AprendeXojo.com and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app, among others.