Re: NSPopUpButtonCell prevents selection update of NSArrayController
Re: NSPopUpButtonCell prevents selection update of NSArrayController
- Subject: Re: NSPopUpButtonCell prevents selection update of NSArrayController
- From: David Spooner <email@hidden>
- Date: Thu, 15 Nov 2007 16:57:17 -0700
If the objects in your array controller have a property which
specifies the available menu options (say as an array of strings),
then you can bind the 'contentValues' of the table column to that
property directly; i.e. bind it to your table view's array controller
with controller key 'arrangedObjects' and model key path the name of
your invented options property...
Cheers,
dave
On 15-Nov-07, at 3:33 PM, Orestis Markou wrote:
I have an NSArrayController that has in the last column an
NSPopUpButtonCell, for a master-detail scenario.
I have used bindings to set it all up and it works.
However, I want to hide some of the MenuItems of the PopUpMenu
depending on the row I am in. For example, according to the type of
the object bound to the row, there are different choices in the pop-
up menu. I can do this using the
menu:updateItem:atIndex:shouldCancel: method.
Here is the bug: the selection of the NSArrayController isn't
updated until *after* the pop-up menu has *closed*. So of course
when accesing selection from within
menu:updateItem:atIndex:shouldCancel:, I get the wrong data. If I
carefully select the row before summoning the menu, everything works
fine.
So, I have three paths:
a) try to somehow intercept the mouse click and deliver it first to
the NSArrayController, then the pop-up cell
b) delay the opening/creation of the pop-up menu until the selection
is updated
c) bypass the controller and its bindings altogether and do the menu
column manually.
I can't find a straightforward way to do any of the above, so please
help!
I am very new to Cocoa, so I may have missed something fundamental.
Please say so.
Thank you,
--
Orestis Markou
email@hidden
http://orestis.gr/
_______________________________________________
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