diff android/DWindows.kt @ 2701:9df2c11f020f

Android: Fix dw_mle_set_word_wrap() and dw_mle_set_cursor(). Calling the wrong method in dw_mle_set_cursor(). Set maxWidth on MLE resize based on Word Wrap setting.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 16 Nov 2021 20:15:18 +0000
parents cee79add3669
children 4f12dc8e8f18
line wrap: on
line diff
--- a/android/DWindows.kt	Tue Nov 16 11:26:19 2021 +0000
+++ b/android/DWindows.kt	Tue Nov 16 20:15:18 2021 +0000
@@ -809,6 +809,17 @@
     }
 }
 
+private class DWMLE(c: Context): androidx.appcompat.widget.AppCompatEditText(c) {
+    protected override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
+        if(!isHorizontalScrollBarEnabled) {
+            this.maxWidth = w
+        } else {
+            this.maxWidth = -1
+        }
+        super.onSizeChanged(w, h, oldw, oldh)
+    }
+}
+
 class DWindows : AppCompatActivity() {
     var windowLayout: ViewPager2? = null
     var threadLock = ReentrantLock()
@@ -2132,7 +2143,7 @@
         waitOnUiThread {
             val dataArrayMap = SimpleArrayMap<String, Long>()
 
-            mle = EditText(this)
+            mle = DWMLE(this)
             mle!!.tag = dataArrayMap
             mle!!.id = cid
             mle!!.isSingleLine = false