Skip navigation.
 
mlRe: NSPopupButton Bindings
FROM : Steve Weller
DATE : Sun Apr 20 06:49:43 2008

On Apr 19, 2008, at 5:58 PM, Johnny Lundy wrote:

> Good evening,
>
> I am having trouble understanding the bindings for NSPopupButton.
>
> View: NSPopupButton
> Controller: NSArrayController, just for the popup button
> Model: NSMutableArray of NSMutableDictionaries.
>
>
> I have the array controller bound to the array in the model, and 
> that is working fine.
>
> My question is: which one of these multiple bindings do I want if I 
> want to have either the popup button's selectedIndex or the actual 
> mutableDictionary at that index passed to my method (I am using 
> another NSButton to invoke the method using the selection of the 
> array controller as an argument).
>
> So far I am getting the proper strings in the popup, but what is 
> getting passed to the method looks like the [dictionary description] 
> of the first item in the model array, no matter what I select in the 
> popupButton.
>
> I've spent the whole day scouring the docs for some guidance in 
> which of the (Content, Content Objects, Content Values, Selected 
> Index, Selected Object, and Selected Value) to use in order to send 
> the model array element (or its index, I can deal with either) as an 
> argument to my method.


I just use the action to get the value I need. For instance, this is 
the action for a pop-up that displays a list of ways a list can be 
sorted. I set up the list dynamically and use bindings to keep the 
view up to date. When an item is selected the action goes here:

// Sort order actions
-(IBAction)sortOrderPopupAction:(id)sender;
{
   
   [self setSortName:[[sender selectedItem] title]];
   [self reSortByName:sortName ascending:sortAscendingOrder];
}

Using the title is not 100% safe since that can change with the 
language.

Related mailsAuthorDate
mlNSPopupButton Bindings Johnny Lundy Apr 20, 02:58
mlRe: NSPopupButton Bindings Steve Weller Apr 20, 06:49
mlFwd: NSPopupButton Bindings Johnny Lundy Apr 20, 15:06
mlRe: NSPopupButton Bindings Johnny Lundy Apr 20, 15:27
mlRe: NSPopupButton Bindings Keary Suska Apr 20, 16:30