|
From: Jonathan P. <jp...@dc...> - 2006-02-11 09:21:14
|
On 10 Feb 2006, at 22:48, Dave Howell wrote:
> currentItem = @outlineView.itemAtRow(@outlineView.selectedRow)
> currentProject = Project.index(currentItem.to_i)
> newProject = currentProject.newProject('Unnamed')
>
> [I'm not passing Ruby objects to the outlineView, just ID numbers.)
> If I now ask
>
> @outlineView.isExpandable(currentItem)
>
> it's "false," no surprise there. Specifically, it's "0". If I try
> to update the view, things actually get worse....
>
> @outlineView.reloadItem(currentItem)
> @outlineView.isExpandable(currentItem)
I think the problem is due to the way items are handled across the
ruby-cocoa bridge.
Cocoa identifies outline view items by ObjC object identity. Although
you are passing ID numbers, they get converted to instances of
NSDecimalNumber. For example, each time ID number '10' is passed,
it'll get a different NSDecimalNumber instance. Therefore, Cocoa will
never think you're referring to the same item.
Try making your items a Ruby subclass of NSObject and passing them
directly, if that's possible. That will ensure the same ObjC instance
is used for each item.
Passing a plain Ruby doesn't work because it gets a new (and
therefore unique) ObjC wrapper object each time it gets passed to
Cocoa-land. I'm not 100% sure about this -- will investigate.
Jonathan
|