1

I have my own custom keyboard created with jetpack compose, in my custom keyboard there's a feature that shows a textfield and we can type that textfield with the keyboard too, so I have to switch between 2 textfield in the same keyboard. Currently I'm using an EditText view to show the textfield and get the input connection for my keyboard with editText.onCreateInputConnection(EditorInfo()) . This is the code:

val editText = EditText(context)
var inputConnection by remember{
    mutableStateOf<InputConnection?>(null)
}
LaunchedEffect(key1 = Unit){
    inputConnection = editText.onCreateInputConnection(EditorInfo()) as InputConnection
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        editText.focusable = FOCUSABLE
    }
}
Column{
    AndroidView(
        factory = { editText },
    )
    CompositionLocalProvider(
        LocalInputConnection provides  inputConnection
    ) {
        MyCustomKeyboard()
    }
}

All working perfectly but I'm wondering is there a way to get the input connection like this in compose version of textfield like material TextField or foundation BasicTextField? Cause I actually already have my own design system's textfield component in compose and don't want to recreate the component in XML. Thank you

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.