【问题标题】:HTML <form> input blocked after WASM loadsWASM 加载后 HTML <form> 输入被阻塞
【发布时间】:2020-07-14 18:25:43
【问题描述】:

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

【问题讨论】:

    标签: html c forms web webassembly


    【解决方案1】:

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

    【讨论】:

    • 谢谢@zakki,我刚刚通过添加解决了这个问题:code emscripten_set_keypress_callback(0, 0, 0, 0); emscripten_set_keydown_callback(0, 0, 0, 0); emscripten_set_keyup_callback(0, 0, 0, 0); code
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 2015-05-11
    • 2022-08-19
    • 2011-01-21
    相关资源
    最近更新 更多