Skip to content

OnKeyEventModifier

A Modifier.Element that registers a keyboard key-press handler on a composable node.

Multiple OnKeyEventModifier elements on the same node are chained: the earlier handler fires first, and the later handler fires only if the event was not yet consumed.

Constructors

OnKeyEventModifier

constructor(onEvent: (UINode, KeyEvent) -> Unit)

Properties

onEvent

Functions

all

open override fun all(predicate: (Modifier.Element<*>) -> Boolean): Boolean

Returns true if predicate returns true for all Elements in this Modifier or if this Modifier contains no Elements.

any

open override fun any(predicate: (Modifier.Element<*>) -> Boolean): Boolean

Returns true if predicate returns true for any Element in this Modifier.

background

@Stable



fun Modifier.background(color: Int): Modifier

Fills the composable's background with a solid ARGB integer color.

@Stable



fun Modifier.background(color: KColor): Modifier

Fills the composable's background with a solid color.

@Stable



fun Modifier.background(startColor: Int, endColor: Int): Modifier

Fills the composable's background with a gradient between two ARGB integer colours.

@Stable



fun Modifier.background(startColor: KColor, endColor: KColor): Modifier

Fills the composable's background with a gradient from startColor to endColor going top-to-bottom.

@Stable



fun Modifier.background(
    startColor: Int, 
    endColor: Int, 
    gradientDirection: GradientDirection = GradientDirection.TOP_TO_BOTTOM
): Modifier

Fills the composable's background with a directional gradient between two ARGB integer colours.

@Stable



fun Modifier.background(
    startColor: KColor, 
    endColor: KColor, 
    gradientDirection: GradientDirection = GradientDirection.TOP_TO_BOTTOM
): Modifier

Fills the composable's background with a gradient from startColor to endColor in the given gradientDirection.

border

@Stable



fun Modifier.border(color: Int, thickness: Int = 1): Modifier

Adds a border using a raw ARGB integer color.

@Stable



fun Modifier.border(color: KColor, thickness: Int = 1): Modifier

Adds a border of thickness pixels and color to the composable.

clipToBounds

Restricts hit-testing of this node's descendants to its own bounds - see ClipToBoundsModifier.

combinedClickable

@Stable



fun <T : UINode> Modifier.combinedClickable(
    onLongClick: (T, PointerEvent) -> Unit? = null, 
    onDoubleClick: (T, PointerEvent) -> Unit? = null, 
    onClick: (T, PointerEvent) -> Unit? = null
): Modifier

Adds multiple click-type handlers to a composable in a single modifier.

At least one of the three callbacks must be non-null.

Parameters

  • onLongClick: Invoked when the node is held for more than LONG_CLICK_THRESHOLD ms.

  • onDoubleClick: Invoked when two presses occur within DOUBLE_CLICK_THRESHOLD ms.

  • onClick: Invoked on a normal single click (mouse release).

debug

@Stable



fun Modifier.debug(vararg strs: String): Modifier

Attaches one or more plain-text debug strings to the composable.

@Stable



fun Modifier.debug(vararg comps: Component): Modifier

Attaches one or more formatted Component debug labels to the composable.

draggable

fun Modifier.draggable(
    state: DraggableState, 
    orientation: Orientation, 
    enabled: Boolean = true, 
    interactionSource: MutableInteractionSource? = null, 
    onDragStarted: () -> Unit = {}, 
    onDragStopped: () -> Unit = {}
): Modifier

Recognizes a drag gesture along orientation and reports each movement as a delta to state - the net.kernelpanicsoft.archie equivalent of Compose Foundation's Modifier.draggable(state, orientation, enabled, interactionSource, onDragStarted, onDragStopped) (dropping startDragImmediately/reverseDirection, which have no equivalent concept here).

Reports only a delta per movement, not an absolute position - a widget whose drag also needs to jump to an absolute position on the initial press (e.g. SliderCore's "click the track to jump there") needs its own press handling for that press-time jump; state only covers the continuous drag that follows, same as Compose Foundation's own Slider doesn't build on plain Modifier.draggable either, for the same reason.

fillMaxHeight

@Stable



fun Modifier.fillMaxHeight(percent: Double = 1.0): Modifier

Forces the node to fill percent of the maximum available height.

fillMaxSize

@Stable



fun Modifier.fillMaxSize(percent: Double = 1.0): Modifier

Forces the node to fill percent of both the available width and height.

fillMaxWidth

@Stable



fun Modifier.fillMaxWidth(percent: Double = 1.0): Modifier

Forces the node to fill percent of the maximum available width.

focusable

@Composable



fun Modifier.focusable(enabled: Boolean = true, interactionSource: MutableInteractionSource? = null): Modifier

Registers this composable as a vanilla keyboard/controller focus-navigation stop - the net.kernelpanicsoft.archie equivalent of Compose Foundation's Modifier.focusable.

Unlike Android's, this can't be backed by an internal Modifier.Node (this framework's modifiers are plain immutable data, not stateful nodes), so the focus flag is remembered here instead - transparent to the caller, but it does mean this overload must be called from a @Composable context, same as any other modifier factory that needs to hold state.

Clickable already applies this (plus Enter/Space activation) for any click-driven widget; reach for this directly only when building an input with a different activation model (e.g. SliderCore, which nudges its value on arrow keys instead).

Parameters

  • enabled: When false, this node drops out of the focus graph entirely - mirrors AbstractWidget.active keeping a disabled vanilla widget out of Tab order.

  • interactionSource: Optional sink for FocusInteraction.Focus/FocusInteraction.Unfocus.

foldIn

open override fun <R> foldIn(initial: R, operation: (R, Modifier.Element<*>) -> R): R

Accumulates a value starting with initial and applying operation to the current value and each element from outside in.

foldOut

open override fun <R> foldOut(initial: R, operation: (Modifier.Element<*>, R) -> R): R

Accumulates a value starting with initial and applying operation to the current value and each element from inside out.

getAll

inline fun <T : Modifier.Element<T>> Modifier.getAll(): List<T>

Collects all Modifier.Element instances of type T from this modifier chain.

height

@Stable



fun Modifier.height(height: Int): Modifier

Sets an exact fixed height of height pixels (width unconstrained).

hoverable

fun Modifier.hoverable(interactionSource: MutableInteractionSource, enabled: Boolean = true): Modifier

Emits HoverInteraction as the pointer enters/exits - matches Compose Foundation's own Modifier.hoverable(interactionSource, enabled) signature exactly. Observe the result via net.kernelpanicsoft.archie.gui.interaction.collectIsHoveredAsState, same as Android; this has no enter/exit callbacks of its own to hook into.

margin

@Stable



fun Modifier.margin(all: Int = 0): Modifier

Adds a uniform margin on all four sides.

@Stable



fun Modifier.margin(horizontal: Int = 0, vertical: Int = 0): Modifier

Adds symmetric horizontal and vertical margins.

@Stable



fun Modifier.margin(
    left: Int = 0, 
    right: Int = 0, 
    top: Int = 0, 
    bottom: Int = 0
): Modifier

Adds independent per-side margins around this composable.

mergeWith

open override fun mergeWith(other: OnKeyEventModifier): OnKeyEventModifier

offset

@Stable



fun Modifier.offset(x: Int = 0, y: Int = 0): Modifier

Shifts the composable by (x, y) pixels after layout.

onCharTyped

Registers a character-typed handler on this composable.

Called when the user types a printable character while the node (or a descendant) participates in key event dispatch.

Parameters

  • onEvent: Callback invoked with (node, CharEvent).

onDrag

@Stable



fun <T : UINode> Modifier.onDrag(global: Boolean = false, onDragEvent: (T, DragEvent) -> Unit): Modifier

Registers a drag event handler on this composable.

Parameters

  • global: When true, the handler fires for drag events anywhere on screen.

  • onDragEvent: The callback invoked with (node, DragEvent).

onGloballyPositioned

fun Modifier.onGloballyPositioned(onGloballyPositioned: (IntCoordinates) -> Unit): Modifier

Registers onGloballyPositioned to be called with the node's absolute screen coordinates every time it is placed (e.g. on layout changes).

onKeyEvent

Registers a key-press handler on this composable.

The handler is called when a keyboard key is pressed while the node (or a descendant) holds focus in the key event dispatch chain.

Parameters

  • onEvent: Callback invoked with (node, KeyEvent).

onPointerEvent

@Stable



fun <T : UINode> Modifier.onPointerEvent(type: PointerEventType, onEvent: (T, PointerEvent) -> Unit): Modifier

Registers a handler for the given pointer type on this composable.

Parameters

  • T: The expected UINode subtype; use UINode for the generic case.

  • type: The PointerEventType to listen for.

  • onEvent: The callback invoked with (node, event) when the event occurs.

onScroll

@Stable



fun <T : UINode> Modifier.onScroll(global: Boolean = false, onScrollEvent: (T, ScrollEvent) -> Unit): Modifier

Registers a scroll event handler on this composable.

Parameters

  • global: When true, the handler fires for scroll events anywhere on screen.

  • onScrollEvent: The callback invoked with (node, ScrollEvent).

onSizeChanged

fun Modifier.onSizeChanged(onSizeChanged: (Size) -> Unit): Modifier

Notifies callback of any size changes to element.

padding

@Stable



fun Modifier.padding(all: Int = 0): Modifier

Adds uniform padding on all four sides.

@Stable



fun Modifier.padding(horizontal: Int = 0, vertical: Int = 0): Modifier

Adds symmetric horizontal and vertical padding.

@Stable



fun Modifier.padding(
    left: Int = 0, 
    right: Int = 0, 
    top: Int = 0, 
    bottom: Int = 0
): Modifier

Adds independent per-side padding inside this composable.

pressable

fun Modifier.pressable(
    interactionSource: MutableInteractionSource, 
    enabled: Boolean = true, 
    onPress: (UINode, Int) -> Unit
): Modifier

Emits PressInteraction and invokes onPress across a press - the net.kernelpanicsoft.archie equivalent of the press-recognition half of Compose Foundation's Modifier.clickable. Observe release via net.kernelpanicsoft.archie.gui.interaction.collectIsPressedAsState rather than a callback - onPress is kept only because, unlike hover, a press is inherently an action (the click itself), not just state to observe.

Fires for any MouseButton, handing the one that pressed to onPress: a widget that only answers to the primary button filters there, and one with a right- or middle-click gesture of its own gets it without a second modifier competing for the same event.

Parameters

  • onPress: Invoked with the receiving node and the MouseButton that pressed it.

selectable

@Composable



fun Modifier.selectable(
    selected: Boolean, 
    enabled: Boolean = true, 
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, 
    onClick: () -> Unit
): Modifier

Marks this composable as a selectable option within a mutually exclusive group (radio button/tab) - the net.kernelpanicsoft.archie equivalent of Compose Foundation's Modifier.selectable.

Same shape as toggleable, but calls onClick unconditionally rather than toggling a boolean - "clicking an already-selected option is a no-op" is the caller's own responsibility (e.g. RadioButtonCore passing onSelect = { if (!selected) onSelect() }), matching real Android's selectable the same way.

size

@Stable



fun Modifier.size(size: Int): Modifier

Sets an exact fixed square size of size × size pixels.

@Stable



fun Modifier.size(width: Int, height: Int): Modifier

Sets an exact fixed size of width × height pixels.

sizeIn

@Stable



fun Modifier.sizeIn(
    minWidth: Int = 0, 
    maxWidth: Int = Integer.MAX_VALUE, 
    minHeight: Int = 0, 
    maxHeight: Int = Integer.MAX_VALUE
): Modifier

Constrains the node's width and height to be within the given min/max bounds.

texture

@Stable



fun Modifier.texture(texture: ResourceLocation): Modifier

Overrides the texture of theme-aware composables with the given ResourceLocation.

then

open infix fun then(other: Modifier): Modifier

Concatenates this modifier with another.

toComponent

open fun toComponent(): Component

Converts this modifier element to a debug Component representation.

toggleable

@Composable



fun Modifier.toggleable(
    value: Boolean, 
    enabled: Boolean = true, 
    interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, 
    onValueChange: (Boolean) -> Unit
): Modifier

Marks this composable as a togglable boolean control (checkbox/switch) - the net.kernelpanicsoft.archie equivalent of Compose Foundation's Modifier.toggleable.

Combines focusable, hoverable, and pressable into one modifier applied directly to the widget's own node - calling onValueChange with !value on press or Enter/Space while focused - so a toggle control doesn't need Clickable's extra wrapping container just to participate in focus/hover/press.

tooltip

@Stable



fun Modifier.tooltip(lines: List<Component>): Modifier

tooltip, for lines a caller already holds as a list.

@Stable



fun Modifier.tooltip(vararg lines: Component): Modifier

Shows lines as a tooltip while the pointer is over this composable.

toString

open override fun toString(): String

unsafeMergeWith

width

@Stable



fun Modifier.width(width: Int): Modifier

Sets an exact fixed width of width pixels (height unconstrained).

zIndex

@Stable



fun Modifier.zIndex(zIndex: Float): Modifier

Sets the rendering depth of this composable relative to its siblings.