New and Improved: Javascript Integration in Awesomium – Prince of Code Blog

In past versions, you could handle the ‘Client’ against not later than mise en scene properties and registering callbacks via WebView::setProperty and WebView::setCallback, severally, and access it via Javascript as a extensive against. This concept has any longer been extended so that you can engender as myriad extensive Javascript objects as you like per WebView-you’re no longer reduced to working with a maiden ‘Client’ against. These objects are linked to the lifetime of the WebView so this call attention to is completely serviceable representing specifying unflagging textbook representing each WebView.
Creating, manipulating, and accessing these objects is merest witless in the unexplored API. To engender an against, entirely bid WebView::createObject with the designate that you necessitate the against to cover up as in Javascript.

Note that WebView::createObject accepts a comprehensive hoax (hence ‘L’, the comprehensive hoax literatim prefix).
For benchmark:
myWebView->createObject(L”MyObject”);
The exposed would engender a extensive Javascript against that you can access as “MyObject” from any entanglement inured to of an adult bellboy flush into your WebView.
Of class, creating objects not isn’t merest useful- to announce the against some properties, you can power WebView::setObjectProperty:
myWebView->setObjectProperty(L”MyObject”, L”name”, “foobar”);
myWebView->setObjectProperty(L”MyObject”, L”color”, “Blue”);
myWebView->setObjectProperty(L”MyObject”, L”level”, 25);
You can insist upon as myriad properties as you necessitate, mise en scene a chattels more than in olden days determination renew the past value. Notice that the finish finally parameter to setObjectProperty accepts a JSValue (more on that later).
Another pleasurable call attention to of these extensive Javascript objects is that you can crowd C++ callbacks to them and invoke events from Javascript. For benchmark:
myWebView->setObjectCallback(L”MyObject”, L”myCallback”);
The exposed rules would child up a unexplored method, “myCallback”, to “MyObject” that, when called from any inured to of an adult bellboy via Javascript, determination invoke WebViewListener::onCallback with the designate of the against, the designate of the callback, and the arguments passed, if any.

Comments are closed.