Re: NSBrowser's current selection
Re: NSBrowser's current selection
- Subject: Re: NSBrowser's current selection
- From: Graham Cox <email@hidden>
- Date: Tue, 21 Jul 2009 11:50:26 +1000
On 21/07/2009, at 11:28 AM, Chase Meadors wrote:
I'm using an NSBrowser with old-fashioned delegate methods. How can
I be notified when the selection changes, and then get the correct
object value for that row and column? Both NSBrowser delegate
methods – browser:selectCellWithString:inColumn: and –
browser:selectRow:inColumn: which the documentation states that "ask
the delegate to select" never get called.
Are you certain the delegate is actually set? Do other delegate
methods get called? How did you set the delegate?
How you determine the relevant object in your data model is up to you
- you have row and column indexes, your controller has to convert that
to some way of referencing the object. Most straightforwardly it can
simply pass the index(es) to NSArray's -objectAtIndex: m ethod.
Then there's the -loadedCellAtRow:Column: method. The documentation
states it "loads, if necessary, the cell and returns." Does this
mean it calls
-browser:willDisplayCell:atRow:Column: to set the value before
returning it?
That's my interpretation, yes, or at any rate, that's how the cell is
given its content whenever necessary. But you must also implement
either - (NSInteger)browser:(NSBrowser *)sender numberOfRowsInColumn:
(NSInteger)column or - (void)browser:(NSBrowser *)sender
createRowsForColumn:(NSInteger)column inMatrix:(NSMatrix *)matrix (but
not both).
--Graham_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden