[MacRuby-devel] ruby structure for NSOutlineView

Watson watson1978 at gmail.com
Sat Nov 26 13:22:55 PST 2011


Hi,

My samples might help you slightly.
 - https://github.com/Watson1978/MacRuby-Samples/tree/master/SourceList
 - https://github.com/Watson1978/MacRuby-Samples/tree/master/SourceList2
 - https://github.com/Watson1978/MacRuby-Samples/tree/master/SourceListBinding

enjoy! :)

2011/11/27 François Boone <francois.boone at usherbrooke.ca>:
> Hi,
> In the same way that this tutorial (http://developer.apple.com/library/mac/#featuredarticles/UsingMacRuby/_index.html), I try to implement a NSOutlineView controller in ruby to make a simple tree in the left part of a window.
> I read the documentation of NSOutlineView, tasks and I understand I have to write at least four methods in my controller class:
>        • – outlineView:child:ofItem:
>        • – outlineView:isItemExpandable:
>        • – outlineView:numberOfChildrenOfItem:
>        • – outlineView:objectValueForTableColumn:byItem:
> My questions are:
> 1) what kind of object I have to use in ruby to fit with outlineView structure?
> If I understand I need a structure like:
> Parent_1 : child 1, child 2
> Parent_2 : no child
> Parent_3 : child 1, child 2, child 3
> 2) Is a Hash like this:
> Hash[ "Parent_1" => ["child 1", child 2"], "Parent_2", Parent_3 => ["child 1", "child 2", "child_3"]]
> can be the solution?
> 3) where I can find this kind of information: the mapping between ruby data structure and NSObject data structure (for future use)?
> 4) and the last one: I think I do not understand what is item in the last method:
> – outlineView:objectValueForTableColumn:byItem:
> item: An item in the data source in the specified tableColumn of the view.
> So, if I want to make a simple tree, I should have just one column, and then item should be Parent_x or child_x: Is it right?
>
> Thank you for reply
> François
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>


More information about the MacRuby-devel mailing list