comparison dwtestoo.cpp @ 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 ac880987a2c4
children ae4d6856b983
comparison
equal deleted inserted replaced
2973:ac880987a2c4 2974:fffb4904c90b
1614 javascript->Append("window.scrollTo(0,500);"); 1614 javascript->Append("window.scrollTo(0,500);");
1615 javascript->Append("window.document.title;"); 1615 javascript->Append("window.document.title;");
1616 javascript->Append("window.navigator.userAgent;"); 1616 javascript->Append("window.navigator.userAgent;");
1617 1617
1618 notebookbox->PackStart(rawhtml, 0, 100, TRUE, FALSE, 0); 1618 notebookbox->PackStart(rawhtml, 0, 100, TRUE, FALSE, 0);
1619 rawhtml->Raw("<html><body><center><h1>dwtest</h1></center></body></html>"); 1619 rawhtml->JavascriptAdd("test");
1620 rawhtml->ConnectMessage([this](std::string name, std::string message) -> int
1621 {
1622 this->app->MessageBox("Javascript Message", DW_MB_OK | DW_MB_INFORMATION,
1623 "Name: " + name + " Message: " + message);
1624 return TRUE;
1625 });
1626 rawhtml->Raw("<html><body><center><h1><a href=\"javascript:test('This is the message');\">dwtest</a></h1></center></body></html>");
1620 DW::HTML *html = new DW::HTML(); 1627 DW::HTML *html = new DW::HTML();
1621 1628
1622 notebookbox->PackStart(hbox, 0, 0, TRUE, FALSE, 0); 1629 notebookbox->PackStart(hbox, 0, 0, TRUE, FALSE, 0);
1623 1630
1624 // Add navigation buttons 1631 // Add navigation buttons
1680 htmlstatus->SetText("Status " + statusnames[status] + ": " + url); 1687 htmlstatus->SetText("Status " + statusnames[status] + ": " + url);
1681 } 1688 }
1682 return FALSE; 1689 return FALSE;
1683 }); 1690 });
1684 1691
1685 html->ConnectResult([this](int status, std::string result, void *script_data) 1692 html->ConnectResult([this](int status, std::string result, void *script_data) -> int
1686 { 1693 {
1687 this->app->MessageBox("Javascript Result", DW_MB_OK | (status ? DW_MB_ERROR : DW_MB_INFORMATION), 1694 this->app->MessageBox("Javascript Result", DW_MB_OK | (status ? DW_MB_ERROR : DW_MB_INFORMATION),
1688 result.size() ? result : "Javascript result is not a string value"); 1695 result.size() ? result : "Javascript result is not a string value");
1689 return TRUE; 1696 return TRUE;
1690 }); 1697 });