diff android/dw.cpp @ 2515:211044d98e86

Android: Initial attempt at our own ComboBox class, EditText with PopupList. Still need to access the internal resource for the down arrow button.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 08 May 2021 01:15:54 +0000
parents 5f711e86a211
children d746323f2841
line wrap: on
line diff
--- a/android/dw.cpp	Fri May 07 19:54:05 2021 +0000
+++ b/android/dw.cpp	Sat May 08 01:15:54 2021 +0000
@@ -1518,6 +1518,20 @@
  */
 void API dw_listbox_append(HWND handle, const char *text)
 {
+    JNIEnv *env;
+
+    if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // Construct a String
+        jstring jstr = env->NewStringUTF(text);
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID listOrComboBoxAppend = env->GetMethodID(clazz, "listOrComboBoxAppend",
+                                                          "(Landroid/view/View;Ljava/lang/String;)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, listOrComboBoxAppend, handle, jstr);
+    }
 }
 
 /*
@@ -1652,6 +1666,21 @@
  */
 HWND API dw_combobox_new(const char *text, ULONG cid)
 {
+    JNIEnv *env;
+
+    if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // Construct a String
+        jstring jstr = env->NewStringUTF(text);
+        // First get the class that contains the method you need to call
+        jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
+        // Get the method that you want to call
+        jmethodID comboBoxNew = env->GetMethodID(clazz, "comboBoxNew",
+                                                 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWComboBox;");
+        // Call the method on the object
+        jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, comboBoxNew, jstr, (int)cid));
+        return result;
+    }
     return 0;
 }