diff android/DWindows.kt @ 2702:4f12dc8e8f18

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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 17 Nov 2021 11:19:06 +0000
parents 9df2c11f020f
children 321e2cf1282a
line wrap: on
line diff
--- 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<String, Long>()
+            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