Button

A clickable button UI element with text content.

Extends TextView to display text and adds click interaction, keyboard support, and visual feedback for hover and pressed states. Supports two visual styles:

  • DEFAULT: Standard button with solid background
  • OVERLAY: Transparent button suitable for overlays

Features:

  • Mouse/touch click support
  • Keyboard navigation (Tab to focus, Enter to click)
  • Visual feedback for hover, pressed, focused, and disabled states
  • Customizable theme integration
  • Transform animation when pressed
See: TextView, Click, TabFocusable

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 button


elements
windowItem: WindowItem

If this field is managed by a WindowItem, this is the WindowItem.


elements
pressed: Bool

Whether the button is currently pressed (mouse/touch down)


elements
inputStyle: Anonymous

Visual style of the button (DEFAULT or OVERLAY)


elements
enabled: Bool

Whether the button is enabled and can be interacted with


elements
focused: Bool

Computed property that returns true if this button has keyboard focus. Updates automatically when focus changes.


elements
invalidateTheme(): Void

elements
invalidateInputStyle(): Void

elements
invalidateEnabled(): Void

elements
invalidateFocused(): Void

elements
invalidateHover(): Void

elements
invalidateEnterPressed(): Void

elements
focus(): Void

Gives keyboard focus to this button. The button will respond to keyboard events when focused.


elements
allowsTabFocus(): Bool

Returns whether this button can receive tab focus. Only enabled buttons can be tab-focused.

Returns Description
Bool True if tab focus is allowed

elements
tabFocus(): Void

Called when this button receives tab focus. Gives keyboard focus to the button.


elements
escapeTabFocus(): Void

Called when escape is pressed while this button has focus. Removes focus from the button.


elements
new(): Void

Creates a new Button with default styling and interaction handlers.

Private Members

elements
unobservedTheme: Theme

elements
click: ceramic.Click

Click detection component for mouse/touch interaction


elements
unobservedInputStyle: Anonymous

elements
unobservedEnabled: Bool

elements
unobservedFocused: Bool

elements
hover: Bool

Tracks mouse hover state


elements
unobservedHover: Bool

elements
enterPressed: Bool

Tracks Enter key press state for visual feedback


elements
unobservedEnterPressed: Bool

elements
emitObservedDirty(instance: Button, fromSerializedField: Bool): Void

Event when any observable value as changed on this instance.

Name Type
instance Button
fromSerializedField Bool

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

Event when theme field changes.

Name Type
current Theme
previous Theme

elements
emitClick(): Void

Emitted when the button is clicked (via mouse, touch, or Enter key)


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

Event when inputStyle field changes.

Name Type
current Anonymous
previous Anonymous

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

Event when enabled field changes.

Name Type
current Bool
previous Bool

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

Event when focused field changes.

Name Type
current Bool
previous Bool

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

Event when hover field changes.

Name Type
current Bool
previous Bool

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

Event when enterPressed field changes.

Name Type
current Bool
previous Bool

elements
handleKeyDown(key: ceramic.Key): Void

Handles key down events. Triggers click on Enter key when focused.

Name Type Description
key ceramic.Key The key event

elements
handleKeyUp(key: ceramic.Key): Void
Name Type
key ceramic.Key

elements
updateStyle(): Void

Updates the button's visual appearance based on its state. Applies different styles for hover, pressed, focused, and disabled states. Includes a subtle transform animation when pressed.

Metadata

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