# InspectorItem
Class
## About
`InspectorItem` maps a user-facing property row to a property on the inspected object. It defines the editor type, caption, validation range, menu choices, default value, enabled state, and optional action caption.
## Enumerations
| Name | Value | Description |
| --- | :---: | --- |
| Editors | Automatic <br > Text <br > MultilineText <br > Number <br > Toggle <br > Menu <br > Color <br > Image <br > File <br > Action | (None) |
## Methods
| Name | Parameters | Return Type | Description |
| --- | :---: | :---: | --- |
| AddChoice | caption As String <br> value As Variant | (None) | Adds a selectable caption and value to this menu item. |
| ChoiceCaptionAt | index As Integer | String | Returns the choice caption at the specified index. |
| ChoiceValueAt | index As Integer | Variant | Returns the choice value at the specified index. |
| Constructor | identifier As String <br> caption As String <br> propertyName As String <br> editor As Editors = Editors.Automatic | (None) | Creates an inspector item initialized with the supplied metadata. |
| DefaultValue | (None) | Variant | Returns the default value used when the inspector item is reset. |
| DefaultValueFor | target As Object <br> ByRef value As Variant <br> template As Object = Nil | Boolean | Returns the value Reset to Default assigns for the supplied target: the explicit default, or the value a newly created object of the target's class has. |
| HasDefaultValue | (None) | Boolean | Returns whether this item has an explicit default value. |
| IsAvailable | target As Object | Boolean | Returns whether the target exposes this item's property. |
| LastChoiceIndex | (None) | Integer | Returns the last zero-based choice index, or -1 when there are no choices. |
| SetDefaultValue | value As Variant | (None) | Sets the value used by the inspector's Reset to Default action. |
| SetValue | target As Object <br> value As Variant | Boolean | Writes the supplied value to this item's property and returns whether it succeeded. |
| Value | target As Object | Variant | Reads this item's property from the supplied target. |
## Properties
| Name | Type | Default Value | Description |
| --- | :---: | :---: | --- |
| ActionCaption | String | "Run" | Gets or sets the label drawn in the value cell for an inspector action. |
| Caption | String | (None) | Gets or sets the user-visible caption. |
| Description | String | (None) | Gets or sets the optional explanatory text. |
| Editor | Editors | (None) | Gets or sets the preferred property editor. |
| Enabled | Boolean | True | Gets or sets whether this item can currently be edited. |
| FileFilter | String | (None) | Gets or sets the open-file dialog filter used by a File editor, such as GraffitiProEditor.ImageFileFilter. Empty allows any file. |
| Identifier | String | (None) | Gets or sets the stable identifier. |
| MaximumValue | Double | 2147483647 | Gets or sets the maximum permitted numeric value. |
| MinimumValue | Double | -2147483648 | Gets or sets the minimum permitted numeric value. |
| PropertyName | String | (None) | Gets or sets the reflected property name. |
| ReadOnly | Boolean | (None) | Gets or sets whether this item is read-only. |
| StepValue | Double | 1 | Gets or sets the numeric increment. |
| UpdatesLive | Boolean | True | Gets or sets whether a text value is applied on every keystroke. Set it to False for values that are expensive or fail while incomplete, such as URLs, so they are applied only when the edit is committed. |
## Notes
Inspector items should expose user-editable state rather than implementation details.
### Menus and Actions
Add menu entries with `AddChoice`, pairing a display caption with the value assigned to the target property. Action items do not assign their mapped property; they call the target's inspector-action handler and draw `ActionCaption` as a button.
### Property Mapping
`PropertyName` must identify a readable property for display and a writable property for editable items. `Automatic` selects an editor from the value type, while explicit editor types provide predictable behavior for text, multiline text, numbers, toggles, colors, files, menus, and actions.
Text values apply on every keystroke, so the document follows along as the user types. Set `UpdatesLive` to False for a value that is expensive or fails while incomplete, such as a URL that loads a resource; it is then applied only when the edit is committed with Return, Tab, or by leaving the field.
A `File` editor opens a file chooser filtered by `FileFilter`. Assign `GraffitiProEditor.ImageFileFilter`, `AudioFileFilter`, or `VideoFileFilter`, or any filter built from `FileType` objects. Empty allows any file.
The inspector resolves properties with Xojo Introspection. Do not apply Xojo's `Hidden` attribute to a class whose properties must appear in the inspector, because hidden classes and members are intentionally omitted from introspection metadata.
Use `ReadOnly` for displayed values that must not be changed and `Enabled` for temporarily unavailable operations. `MinimumValue`, `MaximumValue`, and `StepValue` describe numeric input. Every value item can be reset to its default from a button the inspector shows in its value cell while the value differs, and from the Reset to Default contextual action. The default is the property's value on the registered prototype of the node's class, which is the node new insertions are copied from. Without a prototype, such as for a nested object an item is bound to, it is the value on a newly created object of the target's class, created once per class with the constructor that has the fewest parameters. Xojo Introspection cannot read a parameter's declared default, so that constructor receives empty values. Call `SetDefaultValue` when neither gives the right default. `DefaultValueFor` returns the value a reset assigns; the inspector passes the prototype as its `template`.