LabeledView

Implements: tracker.Observable

A container that pairs a text label with any view, providing flexible label positioning.

LabeledView creates a horizontal layout containing a text label and a generic view of type T. The label can be positioned either to the left or right of the view, and the label's width can be customized. When the label is clicked, it automatically focuses the contained view if it's a FieldView.

Features:

  • Generic type parameter allows any view type
  • Configurable label positioning (LEFT or RIGHT)
  • Adjustable label width
  • Automatic focus delegation from label to view
  • Theme integration for consistent styling
  • Optional container wrapper for complex layouts
  • Automatic disabled state synchronization

Example usage:

var textField = new TextFieldView();
var labeledField = new LabeledView(textField);
labeledField.label = "Name:";
labeledField.labelPosition = LEFT;
labeledField.labelWidth = 100;

Instance Members

elements
observedDirty: Bool

Default is false, automatically set to true when any of this instance's observable variables has changed.


elements
theme: Theme

Custom theme override for this labeled view


elements
label: String

The text content displayed in the label


elements
disabled: Bool

Whether the labeled view is disabled (automatically synced with contained view)


elements
view: elements.LabeledView.T

The main view being labeled


elements
labelPosition: LabelPosition

The position of the label relative to the view (LEFT or RIGHT)


elements
labelWidth: Float

The fixed width of the label (default: 70)


elements
labelViewWidth: Float

Direct access to the label's view width (convenience property)


elements
invalidateTheme(): Void

elements
invalidateLabel(): Void

elements
invalidateDisabled(): Void

elements
new(view: elements.LabeledView.T, ?useContainer: Bool = false): Void

Creates a new LabeledView instance.

Initializes the layout with a text label and the provided view. Sets up automatic styling updates, focus delegation, and proper positioning.

Name Type Default Description
view elements.LabeledView.T The view to be labeled
useContainer Bool false Whether to wrap the view in a container (default: false)

Private Members

elements
unobservedTheme: Theme

elements
unobservedLabel: String

elements
unobservedDisabled: Bool

elements
containerView: ceramic.RowLayout

Optional container view for more complex layouts


elements
useContainer: Bool

Whether to use a container wrapper around the main view


elements
labelText: ceramic.TextView

Internal TextView instance that displays the label text


elements
emitObservedDirty(instance: LabeledView<elements.LabeledView.T>, fromSerializedField: Bool): Void

Event when any observable value as changed on this instance.

Name Type
instance LabeledView<elements.LabeledView.T>
fromSerializedField Bool

elements
emitThemeChange(current: Theme, previous: Theme): Void

Event when theme field changes.

Name Type
current Theme
previous Theme

elements
emitLabelChange(current: String, previous: String): Void

Event when label field changes.

Name Type
current String
previous String

elements
emitDisabledChange(current: Bool, previous: Bool): Void

Event when disabled field changes.

Name Type
current Bool
previous Bool

elements
handleLabelClick(): Void

Handles click events on the label text.

When the label is clicked and the view is not disabled, automatically focuses the contained view if it's a FieldView. This provides intuitive interaction where clicking the label activates the associated input field.


elements
updateLabel(): Void

Updates the label text content.

This method is called automatically when the label property changes to synchronize the displayed text with the current label value.


elements
updateDisabled(): Void

Updates the disabled state by checking the contained view.

Automatically synchronizes the disabled state of this labeled view with the disabled state of the contained view. If the view has a 'disabled' property that is true, this labeled view becomes disabled. Uses unobserve/reobserve to prevent observation cycles.


elements
updateStyle(): Void

Updates the visual styling of the label based on theme and state.

Applies the appropriate text color and font from the current theme:

  • Uses darkTextColor when disabled, lightTextColor when enabled
  • Always uses the medium font from the theme Falls back to the global context theme if no custom theme is set.

Metadata

Name Parameters
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()