ChromiumBrowser:

1. Javascript functions table transfered to example code
2. updated docs
3. layout tooltips updated


git-svn-id: svn://ultimatepp.org/upp/trunk@9036 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
zbych 2015-10-18 15:29:55 +00:00
parent 549a6f3c0f
commit 2a72d5412e
6 changed files with 20 additions and 12 deletions

View file

@ -6,6 +6,8 @@
namespace Upp{
extern const char * const ChromiumBrowserJSFunctions[];
class ChromiumBrowser : public Ctrl {
private:
CefRefPtr<ClientHandler> handler;

View file

@ -1,11 +1,7 @@
#include "ChromiumBrowser.h"
#include "ClientApp.h"
static const char * const func_names[]={
"JSExample1"
};
ClientApp::ClientApp()
{
}
@ -23,9 +19,9 @@ void ClientApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFra
{
//Register our JS functions
CefRefPtr<CefV8Value> object = context->GetGlobal();
for(int f = 0; f < __countof(func_names); f++){
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(func_names[f], this);
object->SetValue(func_names[f], func, V8_PROPERTY_ATTRIBUTE_NONE);
for(int f = 0; Upp::ChromiumBrowserJSFunctions[f] != nullptr; f++){
CefRefPtr<CefV8Value> func = CefV8Value::CreateFunction(Upp::ChromiumBrowserJSFunctions[f], this);
object->SetValue(Upp::ChromiumBrowserJSFunctions[f], func, V8_PROPERTY_ATTRIBUTE_NONE);
}
}

View file

@ -30,9 +30,8 @@ Framework) in Upp application. [* To run CEF you need to download
and compile CEF library] (it is not included in ChromiumBrowser
package due to its size). &]
[s0; &]
[s0; Currently two platforms are supported: Linux/X11 and Windows.
Linux/GTK backend is not supported due to lack of working DHCtrl
class.&]
[s0; Currently three GUI backends are supported: X11, GTK/X11 and
Windows.&]
[s0;* &]
[s0;* &]
[ {{10000F(128)G(128)@1 [s0; [* Building CEF application on Linux]]}}&]

View file

@ -4,7 +4,7 @@ LAYOUT(ChromiumBrowserExampleLayout, 504, 260)
ITEM(Button, Refresh, Tip(t_("Refresh current page")).LeftPosZ(108, 48).TopPosZ(4, 44))
ITEM(EditString, Url, SetFont(StdFontZ(32)).HSizePosZ(160, 160).TopPosZ(4, 44))
ITEM(Button, Go, Tip(t_("Go")).RightPosZ(108, 48).TopPosZ(4, 44))
ITEM(Button, JSTests, SetLabel(t_("JS Test")).Tip(t_("Stop")).RightPosZ(4, 48).TopPosZ(4, 44))
ITEM(Button, JSTests, SetLabel(t_("JS Test")).Tip(t_("Javascript test")).RightPosZ(4, 48).TopPosZ(4, 44))
ITEM(ChromiumBrowser, Browser, StartPage("http://ultimatepp.org").HSizePosZ(0, 0).VSizePosZ(52, 0))
ITEM(Button, Stop, Tip(t_("Stop")).RightPosZ(56, 48).TopPosZ(4, 44))
END_LAYOUT

View file

@ -17,6 +17,7 @@
<p><label style="font-size:30px" id="some_label">Waiting for some action...</label></p>
<p><button style="font-size:30px" onclick="JSExample1('some string', true, 777);">Press me to execute native function from JS!</button></p>
<p><button style="font-size:30px" onclick="JSExample2('second function', 123);">Press me to execute another native function from JS!</button></p>
<script>
function CallbackExample(r)

View file

@ -8,6 +8,16 @@ using namespace Upp;
#include "files.brc"
/* Table of Javascript functions that are forwarded to native code */
const char * const Upp::ChromiumBrowserJSFunctions[]={
"JSExample1",
"JSExample2",
/* DO NOT forget nullptr at the end of the table */
nullptr
};
ChromiumBrowserExample::ChromiumBrowserExample()
{
CtrlLayout(*this, "Embedded Chromium Example " + Browser.GetVersion());