changeset 2607:3b9bbd69bb9c

Android: Implement dw_menu_popup() ... still need to implement the context events.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 16 Jul 2021 02:58:43 +0000
parents 6c30fcc79402
children a11522c30345
files android/DWindows.kt android/dw.cpp
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/android/DWindows.kt	Thu Jul 15 21:22:59 2021 +0000
+++ b/android/DWindows.kt	Fri Jul 16 02:58:43 2021 +0000
@@ -830,6 +830,16 @@
         return darkMode
     }
 
+    fun menuPopup(menu: DWMenu, parent: View, x: Int, y: Int)
+    {
+        runOnUiThread {
+            val popup = PopupMenu(this, parent)
+
+            menu.createMenu(popup.menu)
+            popup.show()
+        }
+    }
+
     fun menuBarNew(location: View): DWMenu?
     {
         // TODO: Make sure location is this activity
--- a/android/dw.cpp	Thu Jul 15 21:22:59 2021 +0000
+++ b/android/dw.cpp	Fri Jul 16 02:58:43 2021 +0000
@@ -4651,6 +4651,20 @@
  */
 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
 {
+    JNIEnv *env;
+
+    if(menu && *menu && parent && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
+    {
+        // 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 menuPopup = env->GetMethodID(clazz, "menuPopup",
+                                               "(Lorg/dbsoft/dwindows/DWMenu;Landroid/view/View;II)V");
+        // Call the method on the object
+        env->CallVoidMethod(_dw_obj, menuPopup, *menu, parent, x, y);
+        _dw_jni_check_exception(env);
+        *menu = nullptr;
+    }
 }
 
 char _dw_removetilde(char *dest, const char *src)