Re: Displaying NSPopUpButtonCells in NSTableView
Re: Displaying NSPopUpButtonCells in NSTableView
- Subject: Re: Displaying NSPopUpButtonCells in NSTableView
- From: James Maxwell <email@hidden>
- Date: Thu, 20 May 2010 14:28:22 -0700
hmm... Well, I've tried returning the cell's selectedItem, indexOfSelectedItem, and also:
[[inst MIDI_Inst_Ports] objectAtIndex:[ports indexOfSelectedItem]]
(that is, the port name at indexOfSelectedItem).
If I NSLog the [ports indexOfSelectedItem] it's always zero. So I'm obviously not understanding how (or when) the cell gets selected.
Maybe the menu/cell selection is a separate process? Do I need to control the popup separately?
I'll look into NSPopUpButtonCell again, but if anyone see's what I'm missing, please pop me a note.
thanks,
J.
On 2010-05-20, at 2:04 PM, James Maxwell wrote:
> ah, that makes sense. I'll make the change and see if that fixes it.
>
> thanks, Peter.
>
> J.
>
>
> On 2010-05-20, at 1:28 PM, Peter Ammon wrote:
>
>>
>> On May 20, 2010, at 1:14 PM, James Maxwell wrote:
>>
>>> I thought I'd change the topic on this, since the content really has changed.
>>>
>>> I have an table for setting up MIDI instruments with a name, port, and channel. I've got the initial display of options for the table row displaying correctly, and when I make changes to the name, port, and channel, the data object is updated correctly. The only thing left is that the popups in columns 2 and 3 are not holding the selected value. I understand that this is probably because I'm reloading the menu in tableView:objectValueForTableColumn:row, but I'm not sure how to get around it.
>>>
>>> Here's the code I've got so far. I'm not using an NSArrayController, because that approach was driving me absolutely mental...
>>> I've copied all the code (except imports) to be thorough. Logging "Edited MIDIInstrument" at the end shows that the instrument is set up correctly, with the desire name, port, and channel. It's just that the popups always display the 2nd item.
>>
>> Hi James,
>>
>> If you have a table view containing an NSPopUpButtonCell, the object value returned by your objectValueForTableColumn: method should be an NSNumber, which contains the index of the item that should be selected. It looks like the attached code is returning the cell itself, which is strange, and I think that's causing the problem.
>>
>> Hope this helps,
>> -Peter
>>
>
> James B Maxwell
> Composer/Doctoral Student
> School for the Contemporary Arts (SCA)
> School for Interactive Arts + Technology (SIAT)
> Simon Fraser University
> email@hidden
> email@hidden
>
> _______________________________________________
>
> 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
James B Maxwell
Composer/Doctoral Student
School for the Contemporary Arts (SCA)
School for Interactive Arts + Technology (SIAT)
Simon Fraser University
email@hidden
email@hidden
_______________________________________________
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