Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
2701:9df2c11f020f | 2702:4f12dc8e8f18 |
---|---|
807 } | 807 } |
808 return rowView | 808 return rowView |
809 } | 809 } |
810 } | 810 } |
811 | 811 |
812 private class DWMLE(c: Context): androidx.appcompat.widget.AppCompatEditText(c) { | 812 private class DWMLE(c: Context): AppCompatEditText(c) { |
813 protected override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { | 813 protected override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { |
814 if(!isHorizontalScrollBarEnabled) { | 814 if(!isHorizontalScrollBarEnabled) { |
815 this.maxWidth = w | 815 this.maxWidth = w |
816 } else { | 816 } else { |
817 this.maxWidth = -1 | 817 this.maxWidth = -1 |
2031 entryfield = EditText(this) | 2031 entryfield = EditText(this) |
2032 | 2032 |
2033 entryfield!!.tag = dataArrayMap | 2033 entryfield!!.tag = dataArrayMap |
2034 entryfield!!.id = cid | 2034 entryfield!!.id = cid |
2035 entryfield!!.isSingleLine = true | 2035 entryfield!!.isSingleLine = true |
2036 entryfield!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) | |
2036 if (password > 0) { | 2037 if (password > 0) { |
2037 entryfield!!.transformationMethod = PasswordTransformationMethod.getInstance() | 2038 entryfield!!.transformationMethod = PasswordTransformationMethod.getInstance() |
2038 } | 2039 } |
2039 entryfield!!.setText(text) | 2040 entryfield!!.setText(text) |
2040 } | 2041 } |
2140 { | 2141 { |
2141 var mle: EditText? = null | 2142 var mle: EditText? = null |
2142 | 2143 |
2143 waitOnUiThread { | 2144 waitOnUiThread { |
2144 val dataArrayMap = SimpleArrayMap<String, Long>() | 2145 val dataArrayMap = SimpleArrayMap<String, Long>() |
2146 val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) | |
2145 | 2147 |
2146 mle = DWMLE(this) | 2148 mle = DWMLE(this) |
2147 mle!!.tag = dataArrayMap | 2149 mle!!.tag = dataArrayMap |
2148 mle!!.id = cid | 2150 mle!!.id = cid |
2149 mle!!.isSingleLine = false | 2151 mle!!.isSingleLine = false |
2150 mle!!.maxLines = Integer.MAX_VALUE | 2152 mle!!.maxLines = Integer.MAX_VALUE |
2151 mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION | 2153 mle!!.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION |
2152 mle!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) | 2154 mle!!.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) |
2153 mle!!.isVerticalScrollBarEnabled = true | 2155 mle!!.isVerticalScrollBarEnabled = true |
2154 mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET | 2156 mle!!.scrollBarStyle = View.SCROLLBARS_INSIDE_INSET |
2155 mle!!.setHorizontallyScrolling(true) | 2157 mle!!.setHorizontallyScrolling(true) |
2156 mle!!.isHorizontalScrollBarEnabled = true | 2158 mle!!.isHorizontalScrollBarEnabled = true |
2157 mle!!.gravity = Gravity.TOP or Gravity.LEFT | 2159 mle!!.gravity = Gravity.TOP or Gravity.LEFT |
2181 | 2183 |
2182 fun mleSetCursor(mle: EditText, point: Int) | 2184 fun mleSetCursor(mle: EditText, point: Int) |
2183 { | 2185 { |
2184 waitOnUiThread { | 2186 waitOnUiThread { |
2185 mle.setSelection(point) | 2187 mle.setSelection(point) |
2188 } | |
2189 } | |
2190 | |
2191 fun mleSetAutoComplete(mle: EditText, state: Int) | |
2192 { | |
2193 waitOnUiThread { | |
2194 val inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_MULTI_LINE) | |
2195 | |
2196 // DW_MLE_COMPLETE_TEXT 1 | |
2197 if((state and 1) == 1) { | |
2198 mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) | |
2199 } else { | |
2200 mle.inputType = (inputType or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) | |
2201 } | |
2186 } | 2202 } |
2187 } | 2203 } |
2188 | 2204 |
2189 fun mleClear(mle: EditText) | 2205 fun mleClear(mle: EditText) |
2190 { | 2206 { |
2780 val newval = text.toLongOrNull() | 2796 val newval = text.toLongOrNull() |
2781 | 2797 |
2782 spinbutton = DWSpinButton(this) | 2798 spinbutton = DWSpinButton(this) |
2783 spinbutton!!.tag = dataArrayMap | 2799 spinbutton!!.tag = dataArrayMap |
2784 spinbutton!!.id = cid | 2800 spinbutton!!.id = cid |
2801 spinbutton!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) | |
2785 spinbutton!!.setText(text) | 2802 spinbutton!!.setText(text) |
2786 if(newval != null) { | 2803 if(newval != null) { |
2787 spinbutton!!.value = newval | 2804 spinbutton!!.value = newval |
2788 } | 2805 } |
2789 } | 2806 } |
2837 val dataArrayMap = SimpleArrayMap<String, Long>() | 2854 val dataArrayMap = SimpleArrayMap<String, Long>() |
2838 | 2855 |
2839 combobox = DWComboBox(this) | 2856 combobox = DWComboBox(this) |
2840 combobox!!.tag = dataArrayMap | 2857 combobox!!.tag = dataArrayMap |
2841 combobox!!.id = cid | 2858 combobox!!.id = cid |
2859 combobox!!.inputType = (InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) | |
2842 combobox!!.setText(text) | 2860 combobox!!.setText(text) |
2843 } | 2861 } |
2844 return combobox | 2862 return combobox |
2845 } | 2863 } |
2846 | 2864 |