|
From: Jonathan P. <jp...@dc...> - 2006-02-17 08:55:52
|
On 17 Feb 2006, at 8:33, Yvon Thoraval wrote:
> in my previous Controller.rb, i've added :
>
> require 'OutlineViewProxyClass.rb'
> include NSOutlineViewable # probably not usefull ?
Yeah, you need to add it specifically to the Ruby class you are
returning from the outline view (after requiring rexml first):
require 'rexml/document'
module REXML
class Element
include NSOutlineViewable
end
end
I see you already have that in 'OutlineViewProxyClass.rb' so it
should be fine.
> i've transformed each bookmark to bookmark.slave seems to be no
> probs here.
>
> However for "def outlineView_child_ofItem(aTree, index, bookmark)"
> i've done :
>
> return @folder.to_nsobj if bookmark.class == NilClass # case of
> root element @folder being a REXML::Element
By including 'to_nsobj' in the REXML::Element class you shouldn't
need to call it explicitly. RubyCocoa looks for a 'to_nsobj' method
when passing a Ruby instance to Cocoa. Also, since 'nil' evaluates as
false in ruby, you could do:
if bookmark then
children = bookmark.slave.get_elements("*")
return children[index]
else
return @folder
end
> and i get an error :
>
> /Users/yvon/work/RubyCocoa/BookmarksMerge/build/Development/
> BookmarksMerge.app/Contents/Resources/OutlineViewProxyClass.rb:
> 14:in `NSApplicationMain': NSApplicationMain -
> RBException_TypeError - can't convert REXML::Element into Integer
> (OSX::OCException)
> from /Users/yvon/work/RubyCocoa/BookmarksMerge/build/Development/
> BookmarksMerge.app/Contents/Resources/rb_main.rb:44
Ah, my fault. A copying-to-Mail.app error crept in.
This line from OutlineViewProxy#init:
@slave = slave
should be
@slave = slave.object_id
That should hopefully fix it.
Jonathan
|