• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Drag highlight problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Drag highlight problems
      • From: Uli Kusterer <email@hidden>
  • Prev by Date: Drag highlight problems
  • Next by Date: Re: Drag highlight problems
  • Previous by thread: Drag highlight problems
  • Next by thread: Re: Drag highlight problems
  • Index(es):
    • Date
    • Thread