Re: Pop Up Menu in NSTableView
Re: Pop Up Menu in NSTableView
- Subject: Re: Pop Up Menu in NSTableView
- From: Quincey Morris <email@hidden>
- Date: Sun, 24 Mar 2013 15:06:11 -0700
On Mar 24, 2013, at 14:50 , Pax <email@hidden> wrote:
You may be more successful if you use a view-based table rather than a cell-based table. One of the reasons we have view-based tables is to be able to avoid dealing with cells directly, in situations like this.
However, if you've never used a view-based table before, the learning curve is fairly steep (though short).
> As to your second question, I've connected the "selector" connection from the cell to 'cellPreferenceChanged'. In my header I have:
> IBOutlet NSPopUpButtonCell* preferenceCell;
> - (IBAction)cellPreferenceChanged:(id)sender;
> and both are hooked up in IB.
Ugh, it doesn't look right to set up an outlet to a cell like this. Table views deal with cells at two points:
1. When obtaining a cell for a given column. It uses the delegate method 'tableView:dataCellForTableColumn:row:' to get the cell, which may or may not be the one that's in the nib file. It does a certain amount of configuration of the cell after this method returns.
2. When preparing the cell for a drawing specific row. It uses the delegate method 'tableView:willDisplayCell:forTableColumn:row:', and does more configuration before this method is called.
So, rather than keeping an outlet to a cell that might not be the one used in any given case, you should use one of the above delegate methods to find out which cell is actually being used.
That's if you need to know the cell in your code, which is doubtful.
> As to the third, how do I find out?
In Xcode, set a breakpoint in the action method. When you get to the breakpoint, go to the debugger console and type the "bt" command. That will give a backtrace you can copy and paste into an email.
_______________________________________________
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