changeset 2808:965c3c6ed1ed

Android: Gray out disabled bitmap buttons... Previously there was no way to visually know if an ImageButton was disabled. This uses a deprecated method, but the new way didn't seem to work... May have a change coming soon if I can get the new method working.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 26 Jul 2022 17:55:26 +0000
parents 975df4680ff7
children f81e92947f4a
files android/DWindows.kt
diffstat 1 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Wed Jul 20 19:22:06 2022 +0000
+++ b/android/DWindows.kt	Tue Jul 26 17:55:26 2022 +0000
@@ -2994,7 +2994,25 @@
 
     fun windowSetEnabled(window: View, state: Boolean) {
         waitOnUiThread {
-            window.setEnabled(state)
+            window.isEnabled = state
+            if(window is ImageButton) {
+                val ib = window as ImageButton
+
+                if(ib.drawable != null) {
+                    if(state) {
+                        ib.drawable.setColorFilter(null)
+                    } else {
+                        ib.drawable.setColorFilter(Color.LTGRAY, PorterDuff.Mode.SRC_IN)
+                    }
+                    if(ib.background != null) {
+                        if(state) {
+                            ib.background.setColorFilter(null)
+                        } else {
+                            ib.background.setColorFilter(Color.LTGRAY, PorterDuff.Mode.SRC_IN)
+                        }
+                    }
+                }
+            }
         }
     }