BooleanFieldView

ceramic.Entityceramic.Visualceramic.Quadceramic.Layerceramic.Viewceramic.LinearLayoutFieldViewelements.BooleanFieldView (Class)

A toggle switch UI element for boolean (true/false) values.

Displays as a sliding switch that can be toggled between on and off states. Supports keyboard navigation (Space to toggle, Enter for on, Backspace/Delete for off) and mouse/touch interaction.

The visual style adapts based on the inputStyle property:

  • DEFAULT: Standard switch with background
  • OVERLAY: Transparent background, suitable for overlays
  • MINIMAL: Minimal style with just borders

Instance Members

elements
theme: Theme

Custom theme override for this field


elements
value: Bool

The current boolean value (true = on, false = off)


elements
inputStyle: Anonymous

Visual style of the switch (DEFAULT, OVERLAY, or MINIMAL)


elements
disabled: Bool

Whether the switch is disabled (non-interactive)


elements
invalidateTheme(): Void

elements
setValue(field: BooleanFieldView, value: Bool): Void

Hook called when the boolean value changes. Override this to handle value updates.

Name Type Description
field BooleanFieldView The field instance (this)
value Bool The new boolean value

elements
invalidateValue(): Void

elements
invalidateInputStyle(): Void

elements
invalidateDisabled(): Void

elements
new(): Void

Creates a new BooleanFieldView with a toggle switch. Sets up the visual components and interaction handlers.

Private Members

elements
unobservedTheme: Theme

elements
switchContainer: ceramic.View

Container view for the switch background


elements
switchSquare: ceramic.View

The sliding square indicator within the switch


elements
unobservedValue: Bool

elements
unobservedInputStyle: Anonymous

elements
unobservedDisabled: Bool

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

Event when theme field changes.

Name Type
current Theme
previous Theme

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

Event when value field changes.

Name Type
current Bool
previous Bool

elements
emitInputStyleChange(current: Anonymous, previous: Anonymous): Void

Event when inputStyle field changes.

Name Type
current Anonymous
previous Anonymous

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

Event when disabled field changes.

Name Type
current Bool
previous Bool

elements
layoutSwitchContainer(): Void

Positions the switch indicator based on the current value. Slides to the right when true, left when false.


elements
handleKeyDown(key: ceramic.Key): Void

Handles keyboard input for the switch.

  • Space: Toggle value
  • Enter: Set to true
  • Backspace/Delete: Set to false
Name Type Description
key ceramic.Key The key event

elements
toggleValue(): Void

Toggles the boolean value between true and false. Calls the setValue hook with the new value.


elements
updateStyle(): Void

Updates the visual style of the switch based on theme and state. Applies different colors and borders for focused, disabled, and value states.

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()