comparison android/DWindows.kt @ 2483:9f7af6d8c6a4

Android: Fix signal handlers so they actually work. Create Weak Global References for the returned jobject handles. The jobject references passed from the event handler will be local references so we need to use IsSameObject() to compare the handles. Also create a more simple entrypoint to reduce calls.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 26 Apr 2021 21:08:02 +0000
parents 4888503c3e3e
children cb5b67154399
comparison
equal deleted inserted replaced
2482:4888503c3e3e 2483:9f7af6d8c6a4
129 fun buttonNew(text: String, cid: Int): Button 129 fun buttonNew(text: String, cid: Int): Button
130 { 130 {
131 val button = Button(this) 131 val button = Button(this)
132 button.text = text 132 button.text = text
133 button.setOnClickListener { 133 button.setOnClickListener {
134 eventHandler(button, null, 8, null, null, 0, 0, 0, 0) 134 eventHandlerSimple(button, 8)
135 } 135 }
136 return button 136 return button
137 } 137 }
138 138
139 fun entryfieldNew(text: String, cid: Int, password: Int): EditText 139 fun entryfieldNew(text: String, cid: Int, password: Int): EditText
149 fun radioButtonNew(text: String, cid: Int): RadioButton 149 fun radioButtonNew(text: String, cid: Int): RadioButton
150 { 150 {
151 val radiobutton = RadioButton(this) 151 val radiobutton = RadioButton(this)
152 radiobutton.text = text 152 radiobutton.text = text
153 radiobutton.setOnClickListener { 153 radiobutton.setOnClickListener {
154 eventHandler(radiobutton, null, 8, null, null, 0, 0, 0, 0) 154 eventHandlerSimple(radiobutton, 8)
155 } 155 }
156 return radiobutton 156 return radiobutton
157 } 157 }
158 158
159 fun checkboxNew(text: String, cid: Int): CheckBox 159 fun checkboxNew(text: String, cid: Int): CheckBox
160 { 160 {
161 val checkbox = CheckBox(this) 161 val checkbox = CheckBox(this)
162 checkbox.text = text 162 checkbox.text = text
163 checkbox.setOnClickListener { 163 checkbox.setOnClickListener {
164 eventHandler(checkbox, null, 8, null, null, 0, 0, 0, 0) 164 eventHandlerSimple(checkbox, 8)
165 } 165 }
166 return checkbox 166 return checkbox
167 } 167 }
168 168
169 fun textNew(text: String, cid: Int, status: Int): TextView 169 fun textNew(text: String, cid: Int, status: Int): TextView
182 * Native methods that are implemented by the 'dwindows' native library, 182 * Native methods that are implemented by the 'dwindows' native library,
183 * which is packaged with this application. 183 * which is packaged with this application.
184 */ 184 */
185 external fun dwindowsInit(dataDir: String): String 185 external fun dwindowsInit(dataDir: String): String
186 external fun eventHandler(obj1: View, obj2: View?, message: Int, str1: String?, str2: String?, int1: Int, int2: Int, int3: Int, int4: Int): Int 186 external fun eventHandler(obj1: View, obj2: View?, message: Int, str1: String?, str2: String?, int1: Int, int2: Int, int3: Int, int4: Int): Int
187 external fun eventHandlerSimple(obj1: View, message: Int)
187 188
188 companion object 189 companion object
189 { 190 {
190 // Used to load the 'dwindows' library on application startup. 191 // Used to load the 'dwindows' library on application startup.
191 init 192 init