Binding Enabled property to NSArrayController selection
Binding Enabled property to NSArrayController selection
- Subject: Binding Enabled property to NSArrayController selection
- From: Matthew Lindfield Seager <email@hidden>
- Date: Mon, 19 Oct 2009 22:08:32 +1100
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?
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