[gambit-list] webView documentation
feeley at iro.umontreal.ca
Sat Dec 7 13:16:34 EST 2013
On Dec 7, 2013, at 9:36 AM, Fuchs Ira <ihf at bit.net> wrote:
> Beginner Q: I am searching for any documentation for (set-webView-content) or (show-webView). They don't appear in the Gambit manual so I presume they are specific to implementations such as the one for Android but where are such OS specific procedures documented?
Gambit REPL for iOS and Gambit for Android are ports of Gambit that add functionality to the base Gambit system. The functions added by these ports are not documented in the Gambit manual. I'm afraid you'll have to read the sources to figure out the details.
I can explain a few of the most useful functions related to webViews. Gambit REPL internally manages 4 webViews, numbered 0 to 3. The webView for the splash screen is number 0. The webView for the editor is number 3. The call
will switch the screen to the webView number n. So (intf#show-view 0) switches to the splash screen.
The content of a webView can be changed by calling intf#set-view-content. The first parameter is the number of the webView to change. The second parameter is a string containing the new HTML content of the page. So the call
(intf#set-view-content 0 "<center>hello</center>")
will show a page containing a centered "hello".
Interaction between the user and a webView is done by installing a handler that intercepts changes to the webView "location". Then each possible event can be encoded by a specific location, for example "event:ok" to indicate that an "ok" button was pressed. So a webView set with
(intf#set-view-content 0 "click <a href=\"event:this\">this</a>")
will generate a change of location to "event:this" when the "this" link is clicked. This change of location is detected by the handler installed with
(cond ((equal? event "event:this")
If the event needs to send extra information, this must be encoded in the string identifying the event.
I hope this helps you understand. For specific examples, see the program.scm file in contrib/GambitREPL .
More information about the Gambit-list