On Aug 12, 2014, at 12:14 PM, Jonathan Taylor <[email protected]> 
wrote:

>>>> My question then is how should I access the tags in the popup menu in 
>>>> order to work out which tag corresponds to the selected item in each row? 
>>> 
>>> If I understand your setup correctly, the most direct route is to set an 
>>> action on each menu item.
>> 
>> Ah ok, I've revisited that and got it to work. I'd tried it before and it 
>> had had no effect; I'd assumed that was something else that just didn't work 
>> with tables. However I've now spotted the compile-time warning about only 
>> sending actions to the table view delegate, and after fixing that it works 
>> nicely. Thanks very much.
>> Jonny
> 
> Actually, I'm not sure that solves my problem as easily as I thought. I'll 
> just restate what I'm trying to achieve to make sure I'm being clear, and 
> then explain the difficulty I'm having in making it work.
> 
> Each menu item string is a user-readable description of a signal channel, 
> each is associated with a numerical channel ID. However there isn't a natural 
> and obvious relationship between the index of the menu item and the channel 
> ID. It seems sensible to me to have the menu item strings defined in the same 
> place as the numerical IDs. I can imagine two ways of doing this:
> 
> 1. Define the menu item strings in InterfaceBuilder as menu items, and give 
> each one a tag representing the channel ID. This is what I have been trying 
> to do, but I can't work out how my code should identify the tag associated 
> with the menu item index (which is what I get in my NSArray representing the 
> current state of the table). I can put an action on the menu item, but at the 
> time that is called I don't know which row's menu has just been selected. 
> Also (rather unexpectedly), putting an action on the menu item seems to 
> prevent the "selected index" binding of the popup cell from being updated.
> 
> 2. Define the menu item strings and associated channel IDs in my code, and 
> use bindings to populate the menu items. I did try that, but haven't managed 
> to get my strings showing up in the menu. Can anyone recommend clear 
> instructions for making that work? I think I maybe don't properly understand 
> the difference between content values and content, and what exactly they need 
> to be bound to...
> 
> Any thoughts about how to make either of these work?

I would create a class, say, SignalChannel, with "name" (for description, but 
we may not ant to use "description" for obvious reasons...) and "channelID" 
properties. I would then populate the NSPopupButtonCell with SignalChannel 
objects. This will abstract the model from the view, which is better form 
anyway.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to