Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Documentation links |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk | v1.0.0 |
Files: | files | file ages | folders |
SHA3-256: |
30b8e128e3727760863ea4c2c5e686e3 |
User & Date: | murphy 2018-09-01 15:28:18.688 |
Context
2018-09-19
| ||
21:10 | Corrected procedure names in documentation check-in: a982f8c954 user: murphy tags: trunk, v1.0.0 | |
2018-09-01
| ||
15:28 | Documentation links check-in: 30b8e128e3 user: murphy tags: trunk, v1.0.0 | |
15:08 | Improved content modification tools check-in: 56a431953b user: murphy tags: trunk | |
Changes
Changes to webview.wiki.
1 2 | <h1>Web View API</h1> | | | | | | | | | | | > > | > > | > > | | > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | <h1>Web View API</h1> <h3 id="m:webview"><tt><nowiki> (import webview) </nowiki></tt></h3> This multi-platform library for [https://www.call-cc.org/|CHICKEN] allows you to show HTML user interfaces in a window, inject JavaScript code and HTML content into the page and receive messages from JavaScript on the page. <h2>Web View</h2> <h3 id="p:webview"><tt><nowiki> (webview? VALUE) ⇒ BOOLEAN </nowiki></tt></h3> Predicate for the tagged pointer type representing a web view window. <h3 id="c:webview"><tt><nowiki> (webview TITLE PROC [#:url URL] [#:width WIDTH] [#:height HEIGHT] [#:resizable? RESIZABLE] [#:debug? DEBUG] [#:yield! YIELD]) ⇒ VOID </nowiki></tt></h3> Creates a web view window with the given <tt>TITLE</tt> and runs an event loop until the user closes the window or termination is requested using [#p:webview-terminate!|<tt>webview-terminate!</tt>]. The message callback is invoked as <tt>(PROC WEBVIEW STRING)</tt> whenever a script on the web page calls <tt>window.external.invoke(STRING)</tt>. If you specify a <tt>URL</tt> that is not <tt>#f</tt>, the page at that location is loaded into the web view. Otherwise, a blank page is loaded which sends a <tt>"load"</tt> message when ready and contains a <tt><div id="app"></tt> element that you can fill with custom content, for example using [#p:webview-html-set!|<tt>webview-html-set!</tt>]. Window properties may be specified using the <tt>WIDTH</tt>, <tt>HEIGHT</tt> and <tt>RESIZABLE</tt> keyword arguments. If the <tt>DEBUG</tt> keyword argument is not <tt>#f</tt> and the platform supports it, the web view will allow access to debugging tools. If <tt>YIELD</tt> is not given or <tt>#f</tt>, the event loop will block the operating system thread when no events are pending. You can set <tt>YIELD</tt> to a number of seconds sleep period between iterations of the web view event loop; this reduces responsiveness of the user interface but allows other CHICKEN threads to run and does not hog the CPU. You can also set <tt>YIELD</tt> to <tt>#t</tt> to call <tt>thread-yield!</tt> between iterations of the event loop; this allows other CHICKEN threads to run without delaying user interface event processing but will use a lot of CPU cycles. <h3 id="p:webview-terminate!"><tt><nowiki> (webview-terminate! WEBVIEW) ⇒ VOID </nowiki></tt></h3> Requests termination of the event loop for the given <tt>WEBVIEW</tt>. <h3 id="p:webview-title-set!"><tt><nowiki> (webview-title-set! WEBVIEW TITLE) ⇒ VOID </nowiki></tt></h3> Sets the <tt>TITLE</tt> of the given <tt>WEBVIEW</tt> window. <h3 id="p:webview-fullscreen-set!"><tt><nowiki> (webview-fullscreen-set! WEBVIEW FULLSCREEN) ⇒ VOID </nowiki></tt></h3> Changes the <tt>FULLSCREEN</tt> state of the given <tt>WEBVIEW</tt> window. <h3 id="p:webview-eval"><tt><nowiki> (webview-eval WEBVIEW SCRIPT) ⇒ VOID </nowiki></tt></h3> Asynchronously triggers evaluation of the given <tt>SCRIPT</tt> code in the context of the page displayed by the given <tt>WEBVIEW</tt>. <h3 id="p:webview-style-set!"><tt><nowiki> (webview-style-set! WEBVIEW SELECTOR PROPERTY VALUE [PRIORITY]) ⇒ VOID </nowiki></tt></h3> Asynchronously triggers a style modification of all DOM elements matching the given <tt>SELECTOR</tt> on the page displayed by the given <tt>WEBVIEW</tt>. The given style <tt>PROPERTY</tt> is set to the given <tt>VALUE</tt> for the selected elements, optionally specifying a <tt>PRIORITY</tt> other than the default. <tt>SELECTOR</tt> is specified as for [https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors|CSS]. <h3 id="p:webview-style-set!"><tt><nowiki> (webview-style-set! WEBVIEW SELECTOR PROPERTY VALUE [PRIORITY]) ⇒ VOID </nowiki></tt></h3> Asynchronously triggers a style modification of all DOM elements matching the given <tt>SELECTOR</tt> on the page displayed by the given <tt>WEBVIEW</tt>. The given style <tt>PROPERTY</tt> is removed from the selected elements. <tt>SELECTOR</tt> is specified as for [https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors|CSS]. <h3 id="p:webview-html-set!"><tt><nowiki> (webview-html-set! WEBVIEW SELECTOR HTML [OUTER?]) ⇒ VOID </nowiki></tt></h3> Asynchronously triggers replacement of the first DOM element matching the given <tt>SELECTOR</tt> on the page displayed by the given <tt>WEBVIEW</tt> with the given <tt>HTML</tt> content. <tt>SELECTOR</tt> is specified as for [https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors|CSS]. <tt>HTML</tt> content is specified in the form accepted by [#p:write-html|<tt>write-html</tt>]. If <tt>OUTER?</tt> is <tt>#f</tt> or not given, only the <em>contents</em> of the specified element are replaced, otherwise the entire element is replaced. <h3 id="p:webview-html-delete!"><tt><nowiki> (webview-html-delete! WEBVIEW SELECTOR [OUTER?]) ⇒ VOID </nowiki></tt></h3> Asynchronously triggers removal of the first DOM element matching the given <tt>SELECTOR</tt> from the page displayed by the given <tt>WEBVIEW</tt>. <tt>SELECTOR</tt> is specified as for [https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors|CSS]. If <tt>OUTER?</tt> is <tt>#f</tt> or not given, only the <em>contents</em> of the specified element are removed, otherwise the entire element is deleted. <h2>Dialogs</h2> <h3 id="p:webview-dialog"><tt><nowiki> (webview-dialog WEBVIEW TITLE TYPE [VALUE]) ⇒ VALUE </nowiki></tt></h3> Shows a modal dialog with the given <tt>TITLE</tt> in the context of the given <tt>WEBVIEW</tt>. If <tt>TYPE</tt> is <tt>#:open</tt> or <tt>#:save</tt>, a file selection |
︙ | ︙ | |||
139 140 141 142 143 144 145 | meaningful result in this case. The running operating system thread will be blocked until the dialog is dismissed. <h2>Logging</h2> | | | | > > | | > | < | | | | | | | | | | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | meaningful result in this case. The running operating system thread will be blocked until the dialog is dismissed. <h2>Logging</h2> <h3 id="p:webview-log"><tt><nowiki> (webview-log MESSAGE) ⇒ VOID </nowiki></tt></h3> Outputs a message using a platform-specific logging mechanism. <h2>Content Generation</h2> <h3 id="m:webview-content"><tt><nowiki> (import webview-content) </nowiki></tt></h3> This support module contains procedures that write [https://developer.mozilla.org/en-US/docs/Web/JavaScript|JavaScript] strings and [https://developer.mozilla.org/en-US/docs/Web/HTML|HTML] document trees with proper escaping. <h3 id="char-set:no-js-escape"><tt><nowiki> char-set:no-js-escape </nowiki></tt></h3> A [https://srfi.schemers.org/srfi-14/srfi-14.html|SRFI-14] set of characters that do not need to be escaped inside a JavaScript string. <h3 id="p:write-js"><tt><nowiki> (write-js STRING [PORT] [QUOTES]) ⇒ VOID </nowiki></tt></h3> Writes a <tt>STRING</tt> to the given <tt>PORT</tt> or the current output port using JavaScript escaping rules. If <tt>QUOTES</tt> is given and not <tt>#f</tt>, its content is printed before and after the <tt>STRING</tt> contents. If <tt>QUOTES</tt> is not given, double quotes are put around the string. <h3 id="p:html-tag-rule"><tt><nowiki> (html-tag-rule TAG) ⇒ RULE </nowiki></tt></h3> <h3><tt><nowiki> (html-tag-rule TAG RULE) ⇒ VOID </nowiki></tt></h3> Retrieves or sets the content rule for HTML elements named <tt>TAG</tt>. The <tt>RULE</tt> can be one of the symbols <tt>normal</tt>, <tt>raw</tt> or <tt>void</tt>. <h3 id="p:write-html"><tt><nowiki> (write-html ELEMENT [PORT]) ⇒ VOID </nowiki></tt></h3> Writes an HTML5 rendering of the X-expression <tt>ELEMENT</tt> to the given <tt>PORT</tt> or the current output port. <tt>ELEMENT</tt> must conform to the following grammar: <verbatim> X-EXPR = ELEMENT | CONTENT ELEMENT = (SYMBOL ((SYMBOL CONTENT ...) ...) X-EXPR ...) ;; element with optional attributes | (SYMBOL X-EXPR ...) ;; element without attributes |
︙ | ︙ |