• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binding the enabled attribute of each NSPopUpButtonCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding the enabled attribute of each NSPopUpButtonCell


  • Subject: Re: Binding the enabled attribute of each NSPopUpButtonCell
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 5 May 2009 21:36:46 -0500

On May 5, 2009, at 8:46 PM, Dave Geering wrote:

I've got a problem when I try to bind the enabled attribute of an
NSPopUpButtonCell.

I have set up an NSArray of custom objects, these custom objects
provide two keys that I want to use for binding (and other keys for
other uses). The two keys are "optionTitle" and "optionAllowed". I
have an array controller in my nib that I bind to my NSArray of custom
objects.

I populate an NSPopUpButton by binding the content to the
arrangedObjects of my array controller with MKP "optionTitle" and this
works fine.

This makes sense because the content of a pop-up button is plural, in the sense that there are multiple items in the pop-up menu.


I'm trying to bind the NSPopUpButtonCell's enabled
attribute to the arrangedObjects of my array controller with MKP
"optionAllowed" but when my view loads an exception is raised saying
that it cannot create a boolean value from an NSCFArray.

What you're asking the frameworks to do here does not make sense. arrangedObjects, as you can see by its name, is plural. There are potentially multiple objects. Consequently, there are potentially multiple optionAllowed values. And yet you're attempting to bind a single value, the enabled state of the pop-up, to multiple values.


Were you under the impression that the enabled state indicated whether each _item_ in the menu was enabled? It does not. It controls whether the pop-up itself is enabled.

I think you want to bind the enabled state of the menu items within the pop-up button cell. I'm not actually sure if that works, but conceptually that's what you seem to want to do. The problem is that the pop-up has some stand-in menu items when it's created in IB, but at runtime the pop-up will be creating its own items based on the content binding. You need to be able to provide a "prototype menu item" (the way that, for example, NSMatrix allows you to specify a prototype cell) with bindings already configured, but I see no way to do that.

Perhaps you can tell the NSPopUpButton not to automatically enable its items (-setAutoenablesItems:NO) and then observe the NSPopUpButtonWillPopUpNotification notification and enable/disable the items in response to that.

Regards,
Ken

_______________________________________________

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


  • Follow-Ups:
    • Re: Binding the enabled attribute of each NSPopUpButtonCell
      • From: Jerry Krinock <email@hidden>
References: 
 >Binding the enabled attribute of each NSPopUpButtonCell (From: Dave Geering <email@hidden>)

  • Prev by Date: Binding the enabled attribute of each NSPopUpButtonCell
  • Next by Date: Re: Binding the enabled attribute of each NSPopUpButtonCell
  • Previous by thread: Binding the enabled attribute of each NSPopUpButtonCell
  • Next by thread: Re: Binding the enabled attribute of each NSPopUpButtonCell
  • Index(es):
    • Date
    • Thread