NSCursor disappears. ItemCursor does not remain set outside the window.

I have a dropdown list status bar containing an NSTableView . When a row is dragged outside the table (dragging and dropping works completely here, this is not the subject of a question). I change the cursor to poofy, otherwise known as [NSCursor disappearingItemCursor] as follows:

 - (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint { if (self.draggedRowCanBeDeleted) { BOOL outside = !NSPointInRect(screenPoint, window.frame); if (outside) { [[NSCursor disappearingItemCursor] set]; } else { [[NSCursor arrowCursor] set]; } } } 

This is pretty unreliable because sometimes it works sometimes. It often works on the first try, but after that it works after that. I can’t find a template with what I am dragging, or how far the drag is moving, etc., It just seems rather unstable. Am I something wrong here? If not, is there something I can do to help diagnose the problem?






UPDATE
I also tried the push / pop route, and the problem persists.

 - (void)draggingSession:(NSDraggingSession *)session movedToPoint:(NSPoint)screenPoint { if (self.draggedRowCanBeDeleted) { BOOL outside = !NSPointInRect(screenPoint, window.frame); if (outside) { if (!_showingPoof) { _showingPoof = YES; [[NSCursor disappearingItemCursor] push]; } } else { if (_showingPoof) { _showingPoof = NO; [[NSCursor disappearingItemCursor] pop]; // I have also tried: [NSCursor pop]; } } } } 






UPDATE
I also tried using the sourceOperationMaskForDraggingContext method to set it. I can confirm that the correct sections are called at the right times, but the cursor never changes when going along this route.

 - (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context { if (self.draggedRowCanBeDeleted) { switch(context) { case NSDraggingContextOutsideApplication: [[NSCursor disappearingItemCursor] set]; return NSDragOperationDelete; break; case NSDraggingContextWithinApplication: [[NSCursor closedHandCursor] set]; return NSDragOperationMove; default: [[NSCursor arrowCursor] set]; return NSDragOperationNone; } } return NSDragOperationNone; } 
+4
source share

All Articles