diff dwtest.c @ 2974:fffb4904c90b

Mac: Initial support for dw_html_javascript_add() and DW_SIGNAL_HTML_MESSAGE for callbacks into native code. Code for iOS next... Then GTK3/4, Windows and Android in that order. Also implemented simple rawhtml tests in the test programs. C++: Added HTML class support for the message callbacks.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 24 Mar 2023 11:39:24 +0000
parents 4b075e64536c
children ae4d6856b983
line wrap: on
line diff
--- a/dwtest.c	Tue Mar 21 00:41:25 2023 +0000
+++ b/dwtest.c	Fri Mar 24 11:39:24 2023 +0000
@@ -2080,6 +2080,14 @@
     return FALSE;
 }
 
+/* Handle web javascript message */
+int DWSIGNAL web_html_message(HWND html, char *name, char *message, void *data)
+{
+    dw_messagebox("Javascript Message", DW_MB_OK | DW_MB_INFORMATION, "Name: %s Message: %s",
+                  name, message);
+    return TRUE;
+}
+
 void html_add(void)
 {
     rawhtml = dw_html_new(1001);
@@ -2095,7 +2103,9 @@
         dw_listbox_append(javascript, "window.navigator.userAgent;");
 
         dw_box_pack_start(notebookbox7, rawhtml, 0, 100, TRUE, FALSE, 0);
-        dw_html_raw(rawhtml, "<html><body><center><h1>dwtest</h1></center></body></html>");
+        dw_html_javascript_add(rawhtml, "test");
+        dw_signal_connect(rawhtml, DW_SIGNAL_HTML_MESSAGE, DW_SIGNAL_FUNC(web_html_message), DW_POINTER(javascript));
+        dw_html_raw(rawhtml, "<html><body><center><h1><a href=\"javascript:test('This is the message');\">dwtest</a></h1></center></body></html>");
         html = dw_html_new(1002);
 
         dw_box_pack_start(notebookbox7, hbox, 0, 0, TRUE, FALSE, 0);