• 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
Re: cocoa-dev digest, Vol 2 #1962 - 14 msgs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cocoa-dev digest, Vol 2 #1962 - 14 msgs


  • Subject: Re: cocoa-dev digest, Vol 2 #1962 - 14 msgs
  • From: Generic User <email@hidden>
  • Date: Wed, 19 Feb 2003 14:24:36 -0600

On Wednesday, February 19, 2003, at 12:53 PM, email@hidden wrote:

In acceptDrop I do

// drag from another document
if(([pboard availableTypeFromArray: [NSArray arrayWithObject:
OV_DRAG_TYPE]] != nil) &&
([info draggingSource] != outlineView))
{
NSData *data = [pboard dataForType: OV_DRAG_TYPE];
NSArray *draggedItems; = [NSUnarchiver unarchiveObjectWithData:
data];
// insert the items
// ...
[outlineView MLselectItems: draggedItems];
}
// drag from this document
if(([pboard availableTypeFromArray: [NSArray arrayWithObject:
OV_DRAG_TYPE]] != nil) &&
([info draggingSource] == outlineView))
{
NSArray *draggedItems; = [self draggedItems];
// move the items
// ...
[outlineView MLselectItems: draggedItems];
}

Alex,

try [outlineView reloadData]; AFTER the item(s) are move but before you call the select method.

NSOutlineView is not like NSTableView. The OV actually caches the items (the whole tree) starting from root, each reload. This is how it is able to "hand" you the EXACT object being dragged, doesn't just tell you which row etc.

So, later when you call [self rowForItem:[items objectAtIndex:i]], it may be returning the ORIGINAL row, which is now, visually invalid for selection. In other words, the OV has updated things visually for you (super nice actually) but it cannot be updating the tree (datasource). Why, because only you know how it is arranged. That's why it is left for you to change your tree as appropriate. But as soon as you do, the OV cache is not the same as your internal model. So, I suspect that when the call is made to programmatically select a row, the OV does a reload on it own, which makes the view and the model the same (the view was already changed for you). Then it attempts to select the row that was passed in, which is now invalid. crash.

I suspect when you drag to a different OV, it can't find the item because it is new and isn't in the cache, so it reloads at that point, the return a good index, selects the row and all is well.

just a hunch.

Regardless, try reloading after you change your tree and before you attempt to select anything. It could solve the problem but maybe not for the reasons I guessed at.

good luck,

BTW, STILL NO LUCK WITH MY ARCHIVING QUESTION!!

d
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Application Security...
  • Next by Date: Fwd: NSDocument and non-file URLs
  • Previous by thread: Re: Cocoa and Java and Menus Oh my...
  • Next by thread: Fwd: NSDocument and non-file URLs
  • Index(es):
    • Date
    • Thread