html - HTML
问题描述
请问有人可以帮我解决这个问题吗?我有画布,插入 html 并在 C 中使用 WebAssembly 绘制,但是它似乎阻止了 HTML 表单输入字段 - 一旦加载并运行了 wasm 模块,我就无法输入任何内容......
我在 C 中使用 emscripten_set_main_loop_arg() 代替 JS 中的 requestAnimationFrame():
const int simulate_infinite_loop = 1; // call the function repeatedly
const int fps = -1; // call the function as fast as the browser wants to render (typically 60fps)
emscripten_set_main_loop_arg(render, &cbp, fps, simulate_infinite_loop);
后来,我将它插入到 HTML 中:
<script type='text/javascript'>
var Module = {};
fetch('app/aghdr.wasm')
.then(response =>
response.arrayBuffer()
).then(buffer => {
Module.canvas = document.getElementById("canvas");
Module.wasmBinary = buffer;
var script = document.createElement('script');
script.src = "app/aghdr.js";
script.onload = function() {
console.log("Emscripten boilerplate loaded.")
}
document.body.appendChild(script);
});
</script>
有人知道,在 WASM 模块运行时确保正常的HTML 表单处理消息很热吗?
见:http: //inters.cloud/test3/
解决方案
可能是由emscripten_set_keypress_callback()
. 当参数回调返回非零时,event.preventDefault()
阻止按键事件。
推荐阅读
- performance - Neo4j 加载 csv 性能问题
- python-3.x - “无法加载本机 TensorFlow 运行时。” 在 cpu 张量流中
- gcc - 从 TCL 执行 cpp/exe
- java - Jackson ObjectMapper 在转换为 POJO 时会忽略某些键
- c# - 从模型中获取字符串值
- codenameone - 仅当任务花费的时间超过设定时间时才显示 InfiniteProgress
- c - 如何从源代码文件中删除未使用的代码块?
- c# - 验证 web api 2 上的空输入或空输入
- linux - 使用 pgrep 确保只运行一个脚本的执行有多安全?
- angular - 捕获错误时显示错误页面(无重定向)角度 2+