diff options
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmcursor.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcursor.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 2b3f37300d..616456b2fa 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -29,6 +29,7 @@ #include "qwasmcursor.h" #include "qwasmscreen.h" +#include "qwasmstring.h" #include <QtCore/qdebug.h> #include <QtGui/qwindow.h> @@ -36,6 +37,8 @@ #include <emscripten/emscripten.h> #include <emscripten/bind.h> +using namespace emscripten; + void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { if (!windowCursor || !window) @@ -54,9 +57,11 @@ void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) htmlCursorName = "auto"; // Set cursor on the canvas - QString canvasId = QWasmScreen::get(screen)->canvasId(); - emscripten::val canvasStyle = emscripten::val::global(canvasId.toUtf8().constData())["style"]; - canvasStyle.set("cursor", emscripten::val(htmlCursorName.constData())); + val jsCanvasId = QWasmString::fromQString(QWasmScreen::get(screen)->canvasId()); + val document = val::global("document"); + val canvas = document.call<val>("getElementById", jsCanvasId); + val canvasStyle = canvas["style"]; + canvasStyle.set("cursor", val(htmlCursorName.constData())); } QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) @@ -68,6 +73,7 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "default"; break; case Qt::UpArrowCursor: + cursorName = "n-resize"; break; case Qt::CrossCursor: cursorName = "crosshair"; @@ -91,7 +97,8 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "nwse-resize"; break; case Qt::SizeAllCursor: - break; // no equivalent? + cursorName = "move"; + break; case Qt::BlankCursor: cursorName = "none"; break; @@ -111,18 +118,23 @@ QByteArray QWasmCursor::cursorShapeToHtml(Qt::CursorShape shape) cursorName = "help"; break; case Qt::BusyCursor: - cursorName = "wait"; + cursorName = "progress"; break; case Qt::OpenHandCursor: - break; // no equivalent? + cursorName = "grab"; + break; case Qt::ClosedHandCursor: - break; // no equivalent? + cursorName = "grabbing"; + break; case Qt::DragCopyCursor: - break; // no equivalent? + cursorName = "copy"; + break; case Qt::DragMoveCursor: - break; // no equivalent? + cursorName = "default"; + break; case Qt::DragLinkCursor: - break; // no equivalent? + cursorName = "alias"; + break; default: break; } |