diff options
author | Liang Qi <liang.qi@qt.io> | 2020-02-13 09:14:09 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-02-13 18:31:40 +0100 |
commit | 6b2535ea15cdbdb2355416b604f072fc13ff36b2 (patch) | |
tree | 4bf1560bab77c8b315850c5337ba31a0ea87b5f0 /src/plugins/platforms/wasm/qwasmeventtranslator.cpp | |
parent | 54c2cebabdda0280b8443c6947b6fee02445e138 (diff) | |
parent | 67491e2df5357706dbf88ddaf1f030ff095b4528 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
examples/widgets/graphicsview/boxes/scene.h
src/corelib/Qt5CoreMacros.cmake
src/corelib/Qt6CoreMacros.cmake
src/network/ssl/qsslsocket.cpp
src/network/ssl/qsslsocket.h
src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
src/testlib/CMakeLists.txt
src/testlib/.prev_CMakeLists.txt
tests/auto/corelib/tools/qscopeguard/tst_qscopeguard.cpp
Disabled building manual tests with CMake for now, because qmake
doesn't do it, and it confuses people.
Done-With: Alexandru Croitor <alexandru.croitor@qt.io>
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I865ae347bd01f4e59f16d007b66d175a52f1f152
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmeventtranslator.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmeventtranslator.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index d99c202c48..3e6043b083 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -339,8 +339,7 @@ QWasmEventTranslator::QWasmEventTranslator(QWasmScreen *screen) void QWasmEventTranslator::initEventHandlers() { - QByteArray _canvasId = screen()->canvasId().toUtf8(); - const char *canvasId = _canvasId.constData(); + QByteArray canvasSelector = "#" + screen()->canvasId().toUtf8(); // The Platform Detect: expand coverage and move as needed enum Platform { @@ -355,30 +354,28 @@ void QWasmEventTranslator::initEventHandlers() g_useNaturalScrolling = false; // make this !default on macOS if (emscripten::val::global("window")["safari"].isUndefined()) { - val document = val::global("document"); - val jsCanvasId = QWasmString::fromQString(screen()->canvasId()); - val canvas = document.call<val>("getElementById", jsCanvasId); + val canvas = screen()->canvas(); canvas.call<void>("addEventListener", val("wheel"), val::module_property("qtMouseWheelEvent")); } } - emscripten_set_keydown_callback(canvasId, (void *)this, 1, &keyboard_cb); - emscripten_set_keyup_callback(canvasId, (void *)this, 1, &keyboard_cb); + emscripten_set_keydown_callback(canvasSelector.constData(), (void *)this, 1, &keyboard_cb); + emscripten_set_keyup_callback(canvasSelector.constData(), (void *)this, 1, &keyboard_cb); - emscripten_set_mousedown_callback(canvasId, (void *)this, 1, &mouse_cb); - emscripten_set_mouseup_callback(canvasId, (void *)this, 1, &mouse_cb); - emscripten_set_mousemove_callback(canvasId, (void *)this, 1, &mouse_cb); + emscripten_set_mousedown_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb); + emscripten_set_mouseup_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb); + emscripten_set_mousemove_callback(canvasSelector.constData(), (void *)this, 1, &mouse_cb); - emscripten_set_focus_callback(canvasId, (void *)this, 1, &focus_cb); + emscripten_set_focus_callback(canvasSelector.constData(), (void *)this, 1, &focus_cb); - emscripten_set_wheel_callback(canvasId, (void *)this, 1, &wheel_cb); + emscripten_set_wheel_callback(canvasSelector.constData(), (void *)this, 1, &wheel_cb); - emscripten_set_touchstart_callback(canvasId, (void *)this, 1, &touchCallback); - emscripten_set_touchend_callback(canvasId, (void *)this, 1, &touchCallback); - emscripten_set_touchmove_callback(canvasId, (void *)this, 1, &touchCallback); - emscripten_set_touchcancel_callback(canvasId, (void *)this, 1, &touchCallback); + emscripten_set_touchstart_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback); + emscripten_set_touchend_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback); + emscripten_set_touchmove_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback); + emscripten_set_touchcancel_callback(canvasSelector.constData(), (void *)this, 1, &touchCallback); } template <typename Event> |