Drag highlight problems
Drag highlight problems
- Subject: Drag highlight problems
- From: John Brownie <email@hidden>
- Date: Mon, 20 Jul 2015 12:36:53 +1000
I have a window with many (up to around 80) views which can be targets
of drag and drop (they can also be sources, but that doesn't appear to
be relevant). Each has a suitable tracking area. I respond to drag enter
and drag exit, and then to drag operation. The basics of the code is below.
- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender
{
self.dragHighlight = YES;
[self setNeedsDisplay:YES];
return NSDragOperationGeneric;
}
- (void)draggingExited:(id<NSDraggingInfo>)sender
{
self.dragHighlight = NO;
[self setNeedsDisplay:YES];
}
- (BOOL)performDragOperation:(id<NSDraggingInfo>)sender
{
self.dragHighlight = NO;
NSPasteboard *pboard = [sender draggingPasteboard];
NSArray *classArray = @[[NSString class]];
NSDictionary *dictionary = @{};
NSArray *draggedItems = [pboard readObjectsForClasses:classArray
options:dictionary];
if (draggedItems != nil && [draggedItems count] > 0) {
// Handle the drag, which will ensure that setNeedsDisplay
is set...
return YES;
}
[self setNeedsDisplay:YES];
return NO;
}
Everything works correctly except for the drag highlight. Sometimes, and
I haven't been able to work out what the sequence is, the drag highlight
will be left on after the drop happens. The problem seems to be some
sort of race condition, but I'm finding it hard to track down. Putting
logging in each of the three methods makes the problem go away, so that
isn't useful.
Am I doing something wrong? I'm on OS X 10.10.4, Xcode 6.4.
John
--
John Brownie, email@hidden or email@hidden
Summer Institute of Linguistics | Mussau-Emira language, Mussau Is.
Ukarumpa, Eastern Highlands Province | New Ireland Province
Papua New Guinea | Papua New Guinea
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden