MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / DoDragDrop

Method DoDragDrop

Source/Engine/Platform/Windows/WindowsWindow.DragDrop.cpp:571–615  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569WindowsGuiData GuiDragDropData;
570
571DragDropEffect Window::DoDragDrop(const StringView& data)
572{
573 // Create background worker that will keep updating GUI (perform rendering)
574 const auto task = New<DoDragDropJob>();
575 Task::StartNew(task);
576 while (task->GetState() == TaskState::Queued)
577 Platform::Sleep(1);
578
579 // Create descriptors
580 FORMATETC fmtetc = { CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
581 STGMEDIUM stgmed = { TYMED_HGLOBAL, { nullptr }, nullptr };
582
583 // Create a HGLOBAL inside the storage medium
584 stgmed.hGlobal = StringToHandle(data);
585
586 // Create drop source
587 auto dropSource = new WindowsDragSource(&fmtetc, &stgmed, 1);
588
589 // Do the drag drop operation
590 DWORD dwEffect;
591 HRESULT result = ::DoDragDrop(dropSource, dropSource, DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK | DROPEFFECT_SCROLL, &dwEffect);
592
593 // Wait for job end
594 Platform::AtomicStore(&task->ExitFlag, 1);
595 task->Wait();
596
597 // Release allocated data
598 dropSource->Release();
599 ReleaseStgMedium(&stgmed);
600
601 // Fix hanging mouse state (Windows doesn't send WM_LBUTTONUP when we end the drag and drop)
602 if (Input::GetMouseButton(MouseButton::Left))
603 {
604 ::POINT point;
605 ::GetCursorPos(&point);
606#if PLATFORM_SDL
607 // Reset the internal button state in SDL
608 SendMessageA((HWND)_handle, WM_LBUTTONUP, 0, MAKELPARAM(point.x, point.y));
609#else
610 Input::Mouse->OnMouseUp(Float2((float)point.x, (float)point.y), MouseButton::Left, this);
611#endif
612 }
613
614 return SUCCEEDED(result) ? dropEffectFromOleEnum(dwEffect) : DragDropEffect::None;
615}
616
617HRESULT Window::DragEnter(Windows::IDataObject* pDataObj, Windows::DWORD grfKeyState, Windows::POINTL pt, Windows::DWORD* pdwEffect)
618{

Callers

nothing calls this directly

Calls 10

StartNewFunction · 0.85
StringToHandleFunction · 0.85
DoDragDropFunction · 0.85
Float2Class · 0.85
dropEffectFromOleEnumFunction · 0.85
AtomicStoreFunction · 0.50
GetStateMethod · 0.45
WaitMethod · 0.45
ReleaseMethod · 0.45
OnMouseUpMethod · 0.45

Tested by

no test coverage detected