diff options
author | Morten Sørvig <morten.sorvig@qt.io> | 2023-02-03 12:59:42 +0100 |
---|---|---|
committer | Morten Sørvig <morten.sorvig@qt.io> | 2023-02-03 18:42:21 +0100 |
commit | 2443f2be07607e44ec483278873702eb0f57ab26 (patch) | |
tree | bbcb961ef744646010a23ccb2e264de7c2978c01 /src/plugins/platforms/wasm/qwasmwindow.cpp | |
parent | 43a77d4b64608edee3782ddbe15da2364b24567e (diff) |
wasm: set contenteditable on canvas
We don't want to make the top-level screen contenteditable,
since that interferes with accessibility. Instead, make
the canvas contenteditable and install clipboard event
handlers there.
Also move follow-up settings which counters some of the
effects contenteditable (outline: none and inputmode: none),
and move aria-hidden.
Pick-to: 6.5
Change-Id: Ibe73d8d097acd948ba8920c781a2003db0a14f3d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmwindow.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmwindow.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 1dc43b61bb..c6c679a0e5 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -18,6 +18,7 @@ #include "qwasmevent.h" #include "qwasmeventdispatcher.h" #include "qwasmaccessibility.h" +#include "qwasmclipboard.h" #include <iostream> #include <sstream> @@ -54,6 +55,20 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmCompositor *compositor, QWasmBackingSt m_canvas["classList"].call<void>("add", emscripten::val("qt-window-content")); + // Set contenteditable so that the canvas gets clipboard events, + // then hide the resulting focus frame. + m_canvas.set("contentEditable", std::string("true")); + m_canvas["style"].set("outline", std::string("none")); + + QWasmClipboard::installEventHandlers(m_canvas); + + // set inputmode to none to stop mobile keyboard opening + // when user clicks anywhere on the canvas. + m_canvas.set("inputmode", std::string("none")); + + // Hide the canvas from screen readers. + m_canvas.call<void>("setAttribute", std::string("aria-hidden"), std::string("true")); + m_windowContents.call<void>("appendChild", m_canvasContainer); m_canvasContainer["classList"].call<void>("add", emscripten::val("qt-window-canvas-container")); |