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

import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.FocusState

class FocusFollowingFocusable(
    manager: FocusFollowingSelectionManager,
    primaryAction: (() -> Unit)?,
    secondaryAction: (() -> Unit)?
) : Focusable<FocusFollowingFocusable>(manager, primaryAction, secondaryAction) {

    val focusRequester = FocusRequester()

    fun setFocus(state: FocusState) {
        if (state.hasFocus) {
            manager.focused = this
        } else if (manager.focused === this) {
            manager.focused = null
        }
    }
}