| 391 | } |
| 392 | |
| 393 | @end |
| 394 | |
| 395 | DragDropEffect SDLWindow::DoDragDrop(const StringView& data) |
| 396 | { |
| 397 | NSWindow* window = (NSWindow*)_handle; |
| 398 | ClipboardDataProviderImpl* clipboardDataProvider = [ClipboardDataProviderImpl alloc]; |
| 399 | clipboardDataProvider->Window = this; |
| 400 | |
| 401 | // Create mouse drag event |
| 402 | NSEvent* event = [NSEvent |
| 403 | mouseEventWithType:NSEventTypeLeftMouseDragged |
| 404 | location:window.mouseLocationOutsideOfEventStream |
| 405 | modifierFlags:0 |
| 406 | timestamp:NSApp.currentEvent.timestamp |
| 407 | windowNumber:window.windowNumber |
| 408 | context:nil |
| 409 | eventNumber:0 |
| 410 | clickCount:1 |
| 411 | pressure:1.0]; |
| 412 | |
| 413 | // Create drag item |
| 414 | NSPasteboardItem* pasteItem = [NSPasteboardItem new]; |
| 415 | [pasteItem setDataProvider:clipboardDataProvider forTypes:[NSArray arrayWithObjects:NSPasteboardTypeString, nil]]; |
| 416 | NSDraggingItem* dragItem = [[NSDraggingItem alloc] initWithPasteboardWriter:pasteItem]; |
| 417 | [dragItem setDraggingFrame:NSMakeRect(event.locationInWindow.x, event.locationInWindow.y, 100, 100) contents:nil]; |
| 418 | |
| 419 | // Start dragging session |
| 420 | NSDraggingSession* draggingSession = [window.contentView beginDraggingSessionWithItems:[NSArray arrayWithObject:dragItem] event:event source:clipboardDataProvider]; |
| 421 | DragDropEffect result = DragDropEffect::None; |
| 422 | |
| 423 | #if USE_EDITOR |
| 424 | //ASSERT(!MacImpl::MacDragSession); |
| 425 | // TODO: Dragging item from dropdown box in a floating window attempts to init dragging twice |
| 426 | if (MacImpl::MacDragSession != nullptr) |
| 427 | return result; |
| 428 | |
| 429 | MacImpl::MacDragSession = draggingSession; |
| 430 | MacImpl::MacDragExitFlag = 0; |
| 431 | MacImpl::DraggingData = data; |
| 432 | MacImpl::DraggingActive = true; |
| 433 | while (Platform::AtomicRead(&MacImpl::MacDragExitFlag) == 0) |
| 434 | { |
| 435 | // The internal event loop will block here during the drag operation, |
| 436 | // events are processed in the event filter callback instead. |
| 437 | SDLPlatform::Tick(); |
| 438 | Platform::Sleep(1); |
| 439 | } |
| 440 | MacImpl::DraggingActive = false; |
| 441 | MacImpl::DraggingData.Clear(); |
| 442 | MacImpl::MacDragSession = nullptr; |
| 443 | #endif |
| 444 | |
| 445 | return result; |
| 446 | } |
| 447 | |
| 448 | DragDropEffect SDLWindow::DoDragDrop(const StringView& data, const Float2& offset, Window* dragSourceWindow) |
| 449 | { |
nothing calls this directly
no test coverage detected