LabeledView
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
Default is false
, automatically set to true
when any of this instance's observable variables has changed.
Custom theme override for this labeled view
The text content displayed in the label
Whether the labeled view is disabled (automatically synced with contained view)
The main view being labeled
The position of the label relative to the view (LEFT or RIGHT)
The fixed width of the label (default: 70)
Direct access to the label's view width (convenience property)
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
Optional container view for more complex layouts
Whether to use a container wrapper around the main view
Internal TextView instance that displays the label text
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 |
Event when theme field changes.
Name | Type |
---|---|
current |
Theme |
previous |
Theme |
Event when label field changes.
Name | Type |
---|---|
current |
String |
previous |
String |
Event when disabled field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
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.
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.
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.
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() |