summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2023-10-11 09:45:55 +1000
committerLorn Potter <lorn.potter@gmail.com>2023-12-21 17:24:42 +1000
commite62fd1b7062af421cd289ff542514bd4332e1933 (patch)
treed8cea005075310fae8da6b5987aa06ed102482d5 /src/plugins/platforms/wasm/qwasmwindowclientarea.cpp
parent5af9c3d0e7e244009ffb4195ebcffb32101d8f04 (diff)
wasm: add QWasmDrag back to handle drag/drop
Change-Id: I7c577e6b13db9f5c51e5691baaf6417b956a5ff4 Done-with: Mikolaj.Boc@qt.io Pick-to: 6.7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmwindowclientarea.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmwindowclientarea.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp b/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp
index 2c9f215760..047b5f432c 100644
--- a/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp
+++ b/src/plugins/platforms/wasm/qwasmwindowclientarea.cpp
@@ -7,6 +7,7 @@
#include "qwasmevent.h"
#include "qwasmscreen.h"
#include "qwasmwindow.h"
+#include "qwasmdrag.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpointingdevice.h>
@@ -31,6 +32,34 @@ ClientArea::ClientArea(QWasmWindow *window, QWasmScreen *screen, emscripten::val
m_pointerUpCallback = std::make_unique<qstdweb::EventCallback>(element, "pointerup", callback);
m_pointerCancelCallback =
std::make_unique<qstdweb::EventCallback>(element, "pointercancel", callback);
+
+ element.call<void>("setAttribute", emscripten::val("draggable"), emscripten::val("true"));
+
+ m_dragStartCallback = std::make_unique<qstdweb::EventCallback>(
+ element, "dragstart", [this](emscripten::val webEvent) {
+ webEvent.call<void>("preventDefault");
+ auto event = *DragEvent::fromWeb(webEvent, m_window->window());
+ QWasmDrag::instance()->onNativeDragStarted(&event);
+ });
+ m_dragOverCallback = std::make_unique<qstdweb::EventCallback>(
+ element, "dragover", [this](emscripten::val webEvent) {
+ webEvent.call<void>("preventDefault");
+ auto event = *DragEvent::fromWeb(webEvent, m_window->window());
+ QWasmDrag::instance()->onNativeDragOver(&event);
+ });
+ m_dropCallback = std::make_unique<qstdweb::EventCallback>(
+ element, "drop", [this](emscripten::val webEvent) {
+ webEvent.call<void>("preventDefault");
+ auto event = *DragEvent::fromWeb(webEvent, m_window->window());
+ QWasmDrag::instance()->onNativeDrop(&event);
+ });
+ m_dragEndCallback = std::make_unique<qstdweb::EventCallback>(
+ element, "dragend", [this](emscripten::val webEvent) {
+ webEvent.call<void>("preventDefault");
+ auto event = *DragEvent::fromWeb(webEvent, m_window->window());
+ QWasmDrag::instance()->onNativeDragFinished(&event);
+ });
+
}
bool ClientArea::processPointer(const PointerEvent &event)