- (BOOL) imageBrowser:(IKImageBrowserView *) aBrowser moveItemsAtIndexes: (NSIndexSet *)indexes toIndex:(NSUInteger)destinationIndex;
This datasource method for reordering in IKImageBrowserView
is not being called. Nib connections have been made correctly. setAllowsReorderdering
is set YES.
But it isn't working yet.
- (void)imageBrowser:(IKImageBrowserView *)aBrowser removeItemsAtIndexes:(NSIndexSet *)indexes
At the same time, the above method for deleting items is correctly called and works perfectly. Why not for reordering ?
When I drag the item to reorder, the following drag and drop code is being called. There are actually 2 IKImageBrowserViews here.
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPoint draggingLocation = [self convertPoint:[sender draggingLocation] fromView:nil];
NSRect contentRect = [[_indexContentBrowserView enclosingScrollView] frame];
BOOL isForContent = (contentRect.origin.x < draggingLocation.x) && (draggingLocation.x < contentRect.origin.x + contentRect.size.width);
if (isForContent)
{
if ([sender draggingSource] == _indexContentBrowserView)
{
return NSDragOperationMove;
}
else
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString * type = [pb availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]];
if(type != nil)
{
return NSDragOperationEvery;
}
}
}
else
{
if ([sender draggingSource] == _indexListBrowserView)
{
return NSDragOperationMove;
}
else
{
NSPasteboard *pb = [sender draggingPasteboard];
NSString * type = [pb availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]];
if(type != nil)
{
return NSDragOperationEvery;
}
}
}
return NSDragOperationNone;
}
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
[super prepareForDragOperation:sender];
if(nil == [sender draggingSource])
return YES;
BOOL success = NO;
if (_galleryMultiImageFileBrowserView != [sender draggingSource])
{
//Code for checking the duplication of files
}
else
{
success = YES;
}
return success;
//I had returned NO here which was the reason for the problem.
}
I found out the problem. It was my mistake. The above code is the corrected one. Earlier, when the [sender draggingSource] was the IKImageBrowserView, it returned NO. That was the reason why the moveItemsAtIndexes: method was not being called.
@Dov: Thank you Dov for giving your precious time. Thanks a lot. @Joaquin: Thank you very much.