Class InspectorField<T, V>Abstract Public Self

The InspectorField class implements a simplified InspectorFieldBase that provides convenient APIs to quickly create a new field inspector based on an underlying UIElementBase control instance.

Type Parameters

  • T extends UIElementBase

    The inspector control type (UIElement that will control the property)

  • V

    The inspector field value type

Hierarchy (view full)

Constructors

  • Creates a new inspectable field.

    Type Parameters

    Parameters

    • type: Type

      The field type

    • control: T

      The control to be rendered in the field

    • labeled: boolean

      If true, will display a label with the field

    • context: InspectorContext

      Context shared by all inspectable fields created by the same parent.

    • title: string

      Name of the property, or some other value to set as the title.

    • path: string

      Full path to this property (includes name of this property and all parent properties).

    • propertyType: EnumValue<InspectablePropertyType, number>
    • depth: number

      Determines how deep within the inspector nesting hierarchy is this field. Some fields may contain other fields, in which case you should increase this value by one.

    • layout: InspectorFormLayoutSection

      Parent layout that all the field elements will be added to.

    • property: InspectableProperty

      Serializable property referencing the field whose contents to display.

    Returns InspectorField<T, V>

Properties

_active: boolean
_depth: number
_disabled: boolean
_formLayoutSection: InspectorFormLayoutSection
_isFocused: boolean
_isReadOnly: boolean
_name: string
_path: string
_propertyType: EnumValue<InspectablePropertyType, number>
_title: string
_type: ClassOf<V>
control: T

The control to be displayed for the field. Can be any UIElement, but a UIControl is preferred.

customElements: {
    attribute: CustomInspectorElementAttribute;
    element: UIElementBase;
}[]

All custom elements added through CustomInspectorElementAttribute on the field.

endUndo: (() => void)

Finishes recording an undo command started via startUndoForPath. If any changes are detected on the field an undo command is recorded onto the undo-redo stack, otherwise nothing is done.

onFieldChanged: ((newValue: ValueTypeOf<V>) => void)

Triggered when the user inputs a new value.

Type declaration

    • (newValue): void
    • Parameters

      Returns void

onFieldChangedImmediate: ((newValue: ValueTypeOf<V>) => void)

Triggered when the user inputs a new value. Sets the property as immediately changed.

Type declaration

    • (newValue): void
    • Parameters

      Returns void

onFieldEditBegan: (() => void)

Triggered when the user confirms input in the field.

onFieldEditEnded: (() => void)

Triggered when the user confirms input in the field.

onFieldInteractionEnded: (() => void)

Triggered when the user has finished interacting with the field but has not confirmed the change yet.

onResetValue: (() => void)

Resets the field to it's default value.

resetButton: UIButton

A button that is shown when the property is not at it's default value. Clicking it reverts the value to the default.

startUndo: (() => void)

Zero parameter wrapper for startUndoForPath

startUndoForPath: ((subPath?: string) => void)

Notifies the system to start recording a new undo command. Any changes to the field after this is called will be recorded in the command. User must call endUndo after field is done being changed.

Type declaration

    • (subPath?): void
    • Parameters

      • OptionalsubPath: string

        Optional path to append to the end of the current field path.

      Returns void

state: EnumValue<InspectableState, number>

The inspectable field modification state.

Accessors

  • get depth(): number
  • Gets the depth of the field.

    Returns number

  • get isActive(): boolean
  • Activates or deactivates the underlying UI elements.

    Returns boolean

  • set isActive(value): void
  • Parameters

    • value: boolean

    Returns void

  • get isDisabled(): boolean
  • Disables or enables the underlying UI elements. Disabled elements cannot be interacted with and have a faded out appearance.

    Returns boolean

  • set isDisabled(value): void
  • Parameters

    • value: boolean

    Returns void

  • get isFocused(): boolean
  • Determines if the field is currently focused.

    Returns boolean

  • get isReadOnly(): boolean
  • Disables or enables the underlying UI elements. Disabled elements cannot be interacted with and have a faded out appearance.

    Returns boolean

  • set isReadOnly(value): void
  • Parameters

    • value: boolean

    Returns void

  • get name(): string
  • Name portion of the field path.

    Returns string

  • get path(): string
  • Returns the path to the field.

    Returns string

Methods

  • Commits the newValue to the inspectable property.

    Parameters

    Returns void

  • Virtual

    Searches for a child field with the specified path.

    Parameters

    • path: string

      Path relative to the current field. Path entries are field names separated with /. Fields within categories are placed within a special category group, surrounded by []. Examples: - myField - myObject/myField - myObject/[myCategory]/myField

    Returns InspectorFieldBase

    Matching field if one is found, null otherwise.

  • Virtual

    Checks if two values of the inspected field are equal. By default, this method uses isEqual to check for equality - if implemented. Complex fields can override this method and offer an alternative comparison method.

    Parameters

    Returns boolean

    True if the two values are equivalent.

  • Virtual

    Notifies the owning inspector that it needs to be refreshed on the next update loop.

    Returns void

  • Notifies the inspector field that it's contents have been modified.

    Parameters

    Returns any

  • Virtual

    Activates or deactivates the underlying UI elements.

    Parameters

    • active: boolean

    Returns void

  • Virtual

    Disables or enables the underlying UI elements. Disabled elements cannot be interacted with and have a faded out appearance.

    Parameters

    • disabled: boolean

    Returns void

  • Virtual

    Moves keyboard focus to this field.

    Parameters

    • OptionalsubFieldName: string

      Name of the sub-field to focus on. Only relevant if the inspectable field represents multiple UI input elements.

    Returns void

  • Virtual

    Set the element read only.

    Parameters

    • readOnly: boolean

      The new read only value

    Returns void

  • Updates all accessory elements of this field.

    Returns void

  • Updates all accessory elements of this field for the currentValue.

    Parameters

    Returns void

  • Creates a new inspectable field, automatically detecting the most appropriate implementation for the type contained in the provided serializable property. This may be one of the built-in inspectable field implemetations (like ones for primitives like int or bool), or a user defined implementation defined with a CustomInspectorAttribute attribute.

    Parameters

    • context: InspectorContext

      Context shared by all inspectable fields created by the same parent.

    • title: string

      Name of the property, or some other value to set as the title.

    • path: string

      Full path to this property (includes name of this property and all parent properties).

    • layoutIndex: number

      Index into the parent layout at which to insert the UI elements for the field .

    • depth: number

      Determines how deep within the inspector nesting hierarchy is this field. Some fields may contain other fields, in which case you should increase this value by one.

    • layout: InspectorFormLayoutSection

      Parent layout that all the field elements will be added to.

    • property: InspectableProperty

      Serializable property referencing the array whose contents to display.

    • Optionalparent: InspectorFieldContainer
    • OptionalfnGetParentFieldConditionals: (() => InspectorFieldConditionalInfo[])

    Returns InspectorFieldBase

    Inspectable field that can be used for displaying the UI for an InspectableProperty of the provided type.

  • Searches for a field with the specified path.

    Parameters

    • path: string

      Path to search for. Path entries are readable field names separated with /. Fields within categories are placed within a special category group, surrounded by []. Examples: - myField - myObject/myField - myObject/[myCategory]/myField

    • depth: number

      Path depth at which the provided set of fields is at.

    • fields: InspectorFieldBase[]

      List of fields to search. Children will be searched recursively.

    Returns InspectorFieldBase

    Matching field if one is found, null otherwise.

  • Returns the top-most part of the provided field path. See findPath2 for more information about paths.

    Parameters

    • path: string

      Path to return the sub-path of.

    • count: number

      Number of path elements to retrieve.

    Returns string

    First count elements of the path.