Pop Up Menu in NSTableView
Pop Up Menu in NSTableView
- Subject: Pop Up Menu in NSTableView
- From: Pascal Harris <email@hidden>
- Date: Sun, 24 Mar 2013 20:47:53 +0000
I have a table which has a list of items on which multiple actions can be performed. Initially, I thought to use check box cells (there are only two possible actions that can be performed on each item right now - so the list of columns is manageable) I thought a little further about the problem and it became apparent to me that, whilst there are only two possible actions right now, there might be twenty in the future - and, given the limited amount of space available to the table, twenty columns might become unmanageable.
My idea, and whether it's good or not remains to be seen, is to use an NSPopUpButtonCell in the NSTableView instead. When an action is selected from the NSPopUpButtonCell the check mark against its name would be toggled (multiple selections would be permitted, so multiple items in the menu might have a check mark next to their names). In this manner, the table would only have two columns (item and menu) and the whole thing would be far more manageable.
SO:
Question 1. Is this possible, and am I even using the correct tool to do the job?
Question 2. Are there any examples of how to achieve what I am trying to do?
At the moment, my code looks like this (nothing is happening yet - I'm just trying to see if I can get the toggle to work - and I can't):
- (IBAction)cellPreferenceChanged:(id)sender
{
[[sender selectedItem] setState:NSOnState];
}
cellPreferenceChanged is bound to the NSPopUpButtonCell in IB. Oddly, despite this binding, this code results in [NSTableView selectedItem]: unrecognized selector sent to instance. Why is this? Surely, since it is the NSPopUpButtonCell that is bound it should be the NSPopUpButtonCell instance for the selected row that is sent?
I am utterly perplexed, and clearly grasping the wrong end of the stick. Any help would be most gratefully received.
_______________________________________________
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