amirisback / keyboard

Custom Keyboard Like Google Keyboard
https://amirisback.github.io/keyboard/
Apache License 2.0
104 stars 24 forks source link

Search View Not Working #51

Closed med1n4 closed 11 months ago

med1n4 commented 1 year ago

Hello @amirisback.

I recently cloned down your project and tried to use the search web view only to find that it wasnt working. When I am focused on the Google search bar and type an input, the text doesnt go into the correct search field. The text goes into the original field that opened the keyboard.

The same thing happens in the Form View too.

I'm wondering if this is a known issue or if there is a fix for this?

Thanks!

rafifrabbani commented 11 months ago

after looking at previous version from this library. I manage to found the solution

paste below code to your KeyboardIME class

override fun onKey(code: Int) {

        val formView = binding?.keyboardForm
        var inputConnection = currentInputConnection

        if (formView?.visibility == View.VISIBLE) {
            val et1 = formView.binding?.etText
            val et1Connection = et1?.onCreateInputConnection(EditorInfo())

            val et2 = formView.binding?.etText2
            val et2Connection = et2?.onCreateInputConnection(EditorInfo())

            val et3 = formView.binding?.etText3
            val et3Connection = et3?.onCreateInputConnection(EditorInfo())

            if (et1?.isFocused == true) {
                inputConnection = et1Connection
            } else if (et2?.isFocused == true) {
                inputConnection = et2Connection
            } else if (et3?.isFocused == true) {
                inputConnection = et3Connection
            }

        } else if (binding?.keyboardWebview?.visibility == View.VISIBLE) {
            inputConnection =
                binding?.keyboardWebview?.binding?.webview?.onCreateInputConnection(EditorInfo())
        } else {
            inputConnection = currentInputConnection
        }
        onKeyExt(code, inputConnection)
    }
amirisback commented 11 months ago

after looking at previous version from this library. I manage to found the solution

paste below code to your KeyboardIME class

override fun onKey(code: Int) {

        val formView = binding?.keyboardForm
        var inputConnection = currentInputConnection

        if (formView?.visibility == View.VISIBLE) {
            val et1 = formView.binding?.etText
            val et1Connection = et1?.onCreateInputConnection(EditorInfo())

            val et2 = formView.binding?.etText2
            val et2Connection = et2?.onCreateInputConnection(EditorInfo())

            val et3 = formView.binding?.etText3
            val et3Connection = et3?.onCreateInputConnection(EditorInfo())

            if (et1?.isFocused == true) {
                inputConnection = et1Connection
            } else if (et2?.isFocused == true) {
                inputConnection = et2Connection
            } else if (et3?.isFocused == true) {
                inputConnection = et3Connection
            }

        } else if (binding?.keyboardWebview?.visibility == View.VISIBLE) {
            inputConnection =
                binding?.keyboardWebview?.binding?.webview?.onCreateInputConnection(EditorInfo())
        } else {
            inputConnection = currentInputConnection
        }
        onKeyExt(code, inputConnection)
    }

can u contribute to this project, please fork and make pull request, I would be happy to @rafifrabbani

amirisback commented 11 months ago

Hello @amirisback.

I recently cloned down your project and tried to use the search web view only to find that it wasnt working. When I am focused on the Google search bar and type an input, the text doesnt go into the correct search field. The text goes into the original field that opened the keyboard.

The same thing happens in the Form View too.

I'm wondering if this is a known issue or if there is a fix for this?

Thanks!

Thank you for your report, will fix asap