Hi, Thank you for reply.
I didn't want to use PXSourceList . I understand it is easier and faster to use something already done. But I would like to understand what I do. And I would like to use ruby … The two first points give me some hint to understand in depth how NSOutlineView and NSButton works. So using only ruby, I am able to manage a NSOutlineView with two columns: the first one is for outline and the second one for the badge. All works fine. I am very happy to have accomplished this, even if that may seem easy for the most people who read this list But, just a "one more thing"… If I use outlineView(outlineView, isGroupItem: item), there is a small offset to the top of the first item. It's very odd Bye François Le 2011-12-12 à 18:32, Watson a écrit : > Hi, > > 1) > NSOutlineViewDelegate Protocol provides you its method. > Please refer to: > http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSOutlineViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSOutlineViewDelegate > > 2) > If you use NSButton, its size might change like as: > > frame = button.frame > frame.size.width = 20 > button.setFrame(frame) > > If make the badge too, it might easily using the > https://github.com/Perspx/PXSourceList :) > > Thanks, > > > 2011/12/13 François Boone <francois.bo...@usherbrooke.ca>: >> Hi, >> >> Thank-you very much Watson for your SourceListViewBased example. >> As usual, I have few questions: >> 1) Where did you find "isGroupItem:item" for OutlineView? I search in >> NSOutlineView Class Reference but I didn't find it! >> 2) I start from your example and I add a column to show a badge for each >> child. It's work, but there is still a small problem I do not understand: >> Even if I set the size with interface inspector, the inline button is always >> the same width of the width of the column when I run the program. >> For instance, the column's width is 70 and I set the button's width to 25. >> >> Thanks for reply >> François >> >> Some explanation and code: >> >> I use the following method found on internet: >> ---- >> "First subclass NSTableCellView and add an IBOutlet for an NSButton and a >> @synthesize/@property statement for it. Then open the NSTableCellView which >> should have a badge in Interface Builder. Set it's class to your newly >> created subclass and add a button to it. Set the button style to "inline" >> and it's type to "switch". >> >> Now select the TableCellView againa and connect the NSButton IBOutlet to >> your added button. That's it. You can now call e.g. [cellView button] >> setTitle@"123"]] to set the rows badge label to 123 or any arbitrary string." >> ---- >> >> So I append to your AppDelegate file the following new class, translated >> from the previous explanation in ruby: >> class MaCellule < NSTableCellView >> attr_accessor :iden >> def initialize >> @iden = NSButton.new >> end >> end >> >> and I change one of your method as follow: >> def outlineView(outlineView, >> viewForTableColumn:tableColumn, >> item:item) >> if (tableColumn.nil?|(tableColumn == outlineView.outlineTableColumn)) >> if item[:type] == "group" >> # group >> view = outlineView.makeViewWithIdentifier("HeaderCell", >> owner:self) >> #puts item['name'] >> view.textField.stringValue = item['name'] >> else >> # child >> # puts item["name"] >> view = outlineView.makeViewWithIdentifier("DataCell", >> owner:self) >> view.imageView.image = item['icon'] >> view.textField.stringValue = item['name'] >> end >> return view >> else >> if item[:group] == "group" >> else >> #puts item["name"] + " 2 " + item["badgeValue"].to_s >> view = outlineView.makeViewWithIdentifier("ButtonCell", >> owner:self) >> #puts view.iden.class >> if item["badgeValue"].empty? >> view.iden.setTransparent(true) >> else >> view.iden.setTitle(item["badgeValue"]) >> end >> end >> end >> end >> >> >> >> >> Le 2011-12-10 à 02:53, Watson a écrit : >> >>> Hi, >>> >>> If you want to display images in NSOutlineView, I think you would use >>> the NSOutlineView as View-Based. >>> You might use the outlineView:viewForTableColumn:item instead of >>> outlineView:objectValueForTableColumn:byItem. >>> >>> Look at my sample, you would think it isn't difficult :) >>> - >>> https://github.com/Watson1978/MacRuby-Samples/tree/master/SourceListViewBased >>> >>> >>> 2011/12/9 François Boone <francois.bo...@usherbrooke.ca>: >>>> Hi, >>>> >>>> With help of Matt and Watson, I have made a tree using Outline View object >>>> and it works fine. >>>> Now I would like to go one step further. >>>> >>>> I would like to use the Source List object available in Object Library. >>>> This Source List looks like Outline View with TableColumn Object. In this >>>> Table Object there is two Table Cell objects, the first one for the header >>>> and the second one, divided in two objects, for an image and a text. >>>> >>>> My question is: how to build the data to fill the Source List object: I >>>> try something like this: >>>> @data = [ [ {:group => 'Title'}], [:cell => {:image => image1, :name => >>>> 'Test'} ] ] where image1 is a NSImage object. >>>> But this doesn't work. >>>> >>>> I don't now why it doesn't work: >>>> 1) a bad structure for @data >>>> 2) a bad binding in xib file >>>> 3) a bad definition of outlineView (I kept the same definition than the >>>> previous Outline View project) >>>> >>>> Thanks for reply >>>> François >>>> >>>> >>>> >>>> _______________________________________________ >>>> MacRuby-devel mailing list >>>> MacRuby-devel@lists.macosforge.org >>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel >>> _______________________________________________ >>> MacRuby-devel mailing list >>> MacRuby-devel@lists.macosforge.org >>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel >>> >> >> _______________________________________________ >> MacRuby-devel mailing list >> MacRuby-devel@lists.macosforge.org >> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel > _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel