Skip to content

ButtonCore

@Composable



fun ButtonCore(
    onClick: (UINode) -> Unit, 
    modifier: Modifier = Modifier, 
    enabled: Boolean = true, 
    content: @Composable



 (isHovered: Boolean, isPressed: Boolean, isFocused: Boolean) -> Unit
)

A stateless clickable container composable.

ButtonCore manages hover, pressed and focus state internally and exposes them to content via the lambda parameters. It handles cursor changes, the full pointer-event lifecycle, and vanilla keyboard/controller focus navigation - Tab/Shift-Tab and arrow keys (via Screen.children()/nextFocusPath) can reach and activate it (Enter/Space) exactly like a plain AbstractWidget, including through controller-navigation mods such as Controlify. It applies no visual styling of its own - isFocused is exposed to content so callers can render their own focus indicator (see Button's themed focused state).

Use ButtonCore when you need custom button visuals. For a standard themed button, use Button instead.

Example

ButtonCore(onClick = { println("Clicked!") }) { isHovered, isPressed, isFocused ->
    Box(
        modifier = Modifier.background(if (isHovered) KColor.LIGHT_GRAY else KColor.GRAY)
            .size(80, 20)
    ) {
        Text(Component.literal("Click me"))
    }
}

Parameters

  • onClick: Invoked with the receiving UINode when the button is pressed (by mouse, or by Enter/Space while vanilla-focused).

  • modifier: Additional modifiers applied to the outer clickable container.

  • enabled: When false, pointer and activation-key events are ignored and no cursor change occurs.

  • content: The button's visual content, receiving isHovered, isPressed and isFocused booleans.