I'm using an IKImageBrowserView for a mac application I'm currently developing and wants to enable dragging inside the IKImageBrowserView so I've used – setAllowsDroppingOnItems: but unfortunately this doesn't allow me to specify which items are eligible as a drop destination so the first part of the question would be if there is a simple and straightforward way to do that.
I've searched the documentation and came up with a way that consists in using the drag delegate method - (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
NSUInteger index = [browserView indexOfItemAtPoint:sender.draggingLocation];
if(index != NSNotFound)
{
WCItemObject *browserCell = (WCItemObject *)[self.items objectAtIndex:index];
NSLog(@"%@", browser开发者_如何学编程Cell.path);
}
Logically, this should be working but, it's not. It only gives the correct object if there are few items (to not display the vertical scroller) which leads me to believe that indexOfItemAtPoint doesn't account for the scroll view so I might need to override it if so (this is the second part of the question) how shall I do it.
I got it working by using indexAtLocationOfDroppedItem (a method of IKImageBrowserView) which from the name and the documentation sounds like if only updates after the drop occurs but it actually updates on hover.
精彩评论