package ch.dissem.yaep.ui.common.focus

import androidx.compose.ui.input.key.KeyEvent

object FocusFollowingSelectionManager : SelectionManager<FocusFollowingFocusable>() {
    init {
        isActive = true
    }

    override fun add(
        primaryAction: (() -> Unit)?,
        secondaryAction: (() -> Unit)?
    ): FocusFollowingFocusable {
        return FocusFollowingFocusable(
            manager = this,
            primaryAction = primaryAction,
            secondaryAction = secondaryAction
        )
    }

    // Key events are ignored, the default focus mechanisms are used
    override fun doOnKeyEvent(event: KeyEvent): Boolean = focused?.child?.onKeyEvent(event) == true

}