# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1637147946 0 # Node ID 4f12dc8e8f182327d195df750c39c125a7acefee # Parent 9df2c11f020f97c31ea43a8dfbffcc6454bb8cc4 Android: Implement dw_mle_set_auto_complete() in the same way as iOS. DW_MLE_COMPLETE_TEXT will enable auto correction on an MLE. Disable dictionary suggestions on most edit/entry fields. diff -r 9df2c11f020f -r 4f12dc8e8f18 android/DWindows.kt --- a/android/DWindows.kt Tue Nov 16 20:15:18 2021 +0000 +++ b/android/DWindows.kt Wed Nov 17 11:19:06 2021 +0000 @@ -809,7 +809,7 @@ } } -private class DWMLE(c: Context): androidx.appcompat.widget.AppCompatEditText(c) { +private class DWMLE(c: Context): AppCompatEditText(c) { protected override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { if(!isHorizontalScrollBarEnabled) { this.maxWidth = w @@ -2033,6 +2033,7 @@ entryfield!!.tag = dataArrayMap entryfield!!.id = cid entryfield!!.isSingleLine = true + entryfield!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) if (password > 0) { entryfield!!.transformationMethod = PasswordTransformationMethod.getInstance() } @@ -2142,6 +2143,7 @@ waitOnUiThread { val dataArrayMap = SimpleArrayMap() + val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) mle = DWMLE(this) mle!!.tag = dataArrayMap @@ -2149,7 +2151,7 @@ mle!!.isSingleLine = false mle!!.maxLines = Integer.MAX_VALUE mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION - mle!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) + mle!!.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) mle!!.isVerticalScrollBarEnabled = true mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET mle!!.setHorizontallyScrolling(true) @@ -2186,6 +2188,20 @@ } } + fun mleSetAutoComplete(mle: EditText, state: Int) + { + waitOnUiThread { + val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) + + // DW_MLE_COMPLETE_TEXT 1 + if((state and 1) == 1) { + mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) + } else { + mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) + } + } + } + fun mleClear(mle: EditText) { waitOnUiThread { @@ -2782,6 +2798,7 @@ spinbutton = DWSpinButton(this) spinbutton!!.tag = dataArrayMap spinbutton!!.id = cid + spinbutton!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) spinbutton!!.setText(text) if(newval != null) { spinbutton!!.value = newval @@ -2839,6 +2856,7 @@ combobox = DWComboBox(this) combobox!!.tag = dataArrayMap combobox!!.id = cid + combobox!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) combobox!!.setText(text) } return combobox diff -r 9df2c11f020f -r 4f12dc8e8f18 android/dw.cpp --- a/android/dw.cpp Tue Nov 16 20:15:18 2021 +0000 +++ b/android/dw.cpp Wed Nov 17 11:19:06 2021 +0000 @@ -2733,6 +2733,19 @@ */ void API dw_mle_set_auto_complete(HWND handle, int state) { + JNIEnv *env; + + if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + // First get the class that contains the method you need to call + jclass clazz = _dw_find_class(env, DW_CLASS_NAME); + // Get the method that you want to call + jmethodID mleSetAutoComplete = env->GetMethodID(clazz, "mleSetAutoComplete", + "(Landroid/widget/EditText;I)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, mleSetAutoComplete, handle, state); + _dw_jni_check_exception(env); + } } /*