• 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 Enabled property to NSArrayController selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding Enabled property to NSArrayController selection


  • Subject: Re: Binding Enabled property to NSArrayController selection
  • From: Stamenkovic Florijan <email@hidden>
  • Date: Mon, 19 Oct 2009 07:51:09 -0400

Hi Matthew,

On Oct 19, 2009, at 07:08, Matthew Lindfield Seager wrote:

As discussed previously on this list I am using the data source methods of
NSOutlineView to display the contents of two separate NSArrayControllers.
When an item is selected I use outlineViewSelectionDidChange: to manually
update the selection of the appropriate array controller and deselect all
items in the other array controller (i.e. I pass an empty index set to
setSelectionIndexes).


I would like a toolbar item to only be enabled when an item in the first
controller is selected so I tried binding it's Enabled property to
selectedObjects.@count and then canRemove. With either binding when the
selection changes I see the button flicker as though it is being disabled
and then reenabled but it never stays disabled.


I verified that empty selections are allowed. I am observing changes to the
outline view's selectionIndex and I can verify that even though
[[myArrayController selectedObjects] count] == 0, the item is not [staying?]
disabled. Using the "No Selection Placeholder" value doesn't make a
difference either.


Out of curiosity/desparation I even tried the inverse (enabling it when an
object from the other array controller is selected) and two different
complements (disabling it when an object from the other array controller is
selected AND disabling it when an abject from this controller is not
selected). No matter what I tried it would only flicker when I was expecting
it to stop being enabled. Am I missing something obvious?

I think so... When binding the enabled state of a toolbar item you need to make sure that the item does not autovalidate. The "Autovalidates" checkbox can be found in the attributes panel of the inspector for a toolbar item. I am not sure if this is a bug or not, and it is NOT mentioned in the bindings reference for NSToolbarButton, so it's a bit tricky to figure out. Since usually bindings override the non-bound state I can see this as a bug, but my experience with Cocoa is not wide enough to judge... Anyone else?


Regards,
Matt

P.S. The following two threads <rhetorical>(from quite some time ago - is
Leopard REALLY that old?)</rhetorical> seem to discuss something similar but
neither post was answered.
http://www.cocoabuilder.com/archive/message/cocoa/2007/1/6/176732
http://www.cocoabuilder.com/archive/message/cocoa/2007/12/28/195544
_______________________________________________

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 Enabled property to NSArrayController selection
      • From: Matthew Lindfield Seager <email@hidden>
References: 
 >Binding Enabled property to NSArrayController selection (From: Matthew Lindfield Seager <email@hidden>)

  • Prev by Date: Re: NSInvocationOperations and background Threads
  • Next by Date: Re: Binding Enabled property to NSArrayController selection
  • Previous by thread: Binding Enabled property to NSArrayController selection
  • Next by thread: Re: Binding Enabled property to NSArrayController selection
  • Index(es):
    • Date
    • Thread