首页 > 解决方案 > HTML

WASM 加载后输入被阻塞

问题描述

请问有人可以帮我解决这个问题吗?我有画布,插入 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/

标签: htmlcformswebwebassembly

解决方案


可能是由emscripten_set_keypress_callback(). 当参数回调返回非零时,event.preventDefault()阻止按键事件。


推荐阅读