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 17:12:13 -0700
On 15-Nov-07, at 5:04 PM, Markou Orestis wrote:
That's a nice approach. I haven't thought of that...
It's a bit contrived, from an OO point of view, but it will save me
a lot of trouble.
I beg to differ. Yes the menu options are being associated with the
model objects, seeming mixing interface-level code with the model-
level. But the association is quite loose -- the defining methods can
be added in categories of the model classes in separate files and even
in separate frameworks entirely. So there is really no 'pollution' of
the model at all...
Thanks!
--
Orestis Markou
You're welcome.
dave
On 16 Νοε 2007, at 1:57 ΠΜ, David Spooner wrote:
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