Re: what's an easy way to use NSBrowser?
Re: what's an easy way to use NSBrowser?
- Subject: Re: what's an easy way to use NSBrowser?
- From: Sherm Pendley <email@hidden>
- Date: Wed, 17 May 2006 21:20:13 -0400
On May 17, 2006, at 6:30 PM, Alan Smith wrote:
What does the browser expect when it calls
"browser:willDisplayCell:atRow:column:"? It doesn't return anything.
With a "passive" delegate, you implement -
browser:numberOfRowsInColumn:, and the browser automatically creates
an NSCell object that's re-used for every item in a column. The
browser calls -browser:willDisplayCell:atRow:column: for each row
that's visible. In this method, you need to assign the correct value
to the display cell.
The alternative is an "active" delegate, where you create an array of
NSCell objects yourself, and add them to the matrix passed to -
browser:createRowsForColumn:inMatrix:. You're creating the cells
yourself, and you're not re-using the same one for every row, so you
can simply initialize them with the correct value at creation time.
In that case you wouldn't need to implement -
browser:willDisplayCell:atRow:column: like you would for for an
passive delegate.
There will be a NSBrowser with ONLY two columns, it won't be able to
go beyond that. The user will select one of the three items in the
column on the left. If the row selected was "EV Nova" the second
column will display the contents of the folder at "~/Application
Support/EV Manager/EV Nova Pilots" How can I do this on 10.3 so that
it is compatible with 10.1 throuth 10.4?
In numberOfRows, check the column argument - if it's 0, you've got
three rows, otherwise you need to check the current selection path in
the browser. Based on the selection in the first column, you can find
the number of files (or whatever) you'll be showing in the second.
In willDisplayCell, again check the column argument. With only three
elements in the first column, I'd just code a hard-coded list of
values and a simple switch statement. For the second column, once
again check the current selection in the first to see which folder to
scan. Choose the Nth filename in the folder, where N is the row, and
pass the filename to the cell's -setStringValue:.
sherm--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden