ColorFieldView
A color input field with an integrated color picker popup.
This field provides multiple ways to input colors:
- Direct hex color input (#RRGGBB format)
- Visual color preview box that opens a color picker when clicked
- Full-featured color picker with HSB/HSLuv spectrum and sliders
The field validates hex input in real-time and shows a live preview. The color picker appears as a floating popup positioned intelligently to stay within screen bounds.
Features:
- Hex color validation with automatic formatting
- Live color preview
- Floating color picker with triangle pointer
- Smart positioning to avoid screen edges
- Keyboard shortcuts (Escape to close, Enter/Space to toggle)
- Theme-aware styling
- Disabled state support
Example usage:
var colorField = new ColorFieldView();
colorField.value = Color.BLUE;
colorField.setValue = (field, color) -> {
myObject.color = color;
};
Instance Members
The theme to use for styling. If null, uses the global context theme.
The current color value. Updates the hex display and color preview when changed.
Whether the field is disabled. Disabled fields cannot be edited and appear dimmed.
Hook function called when the color value changes. Override this to handle color changes.
Name | Type | Description |
---|---|---|
field |
ColorFieldView | The color field that changed |
value |
ceramic.Color | The new color value |
Focuses the field and activates text editing.
Name | Type |
---|---|
x |
Float |
y |
Float |
Returns |
---|
Bool |
Name | Type |
---|---|
scanCode |
ceramic.ScanCode |
Returns |
---|
Bool |
Name | Type |
---|---|
keyCode |
ceramic.KeyCode |
Returns |
---|
Bool |
Creates a new ColorFieldView.
Initializes:
- Hex color text input with # prefix
- Color preview box
- Hidden color picker container
- Keyboard shortcuts and event handlers
- Theme-based styling
Private Members
Regular expression to validate complete 6-digit hex color codes.
Regular expression to validate partial hex color input.
Whether the color picker popup is currently visible.
Event when theme field changes.
Name | Type |
---|---|
current |
Theme |
previous |
Theme |
Event when value field changes.
Name | Type |
---|---|
current |
ceramic.Color |
previous |
ceramic.Color |
Event when disabled field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Event when pickerVisible field changes.
Name | Type |
---|---|
current |
Bool |
previous |
Bool |
Handles focus loss by validating and correcting the hex input. If the input is empty or invalid, resets to the current color value.
Validates and processes hex color input from the text field. Handles various input formats (#RRGGBB, 0xRRGGBB, RRGGBB). Updates the color value if valid, otherwise reverts to current value.
Name | Type | Description |
---|---|---|
text |
String | The input text to validate |
Updates the UI elements to reflect the current color value. Updates the hex text display and color preview box.
Creates or destroys the color picker popup based on visibility state. Handles picker creation, positioning, and color synchronization.
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
tracker.macros.ObservableMacro.build() |
:autoBuild |
tracker.macros.ObservableMacro.build() |