Enabled Binding bound to NSArrayController won't disable view.
-
I have a tableview who's enabled binding is bound to a
NSArrayController (not the one that feeds it via its content
binding). I'd like to be enabled when something is selected and
disabled when it is not. So far I've been unable to find a suitable
key to bind to on the array controller. It seems like you should
just be able to bind to selection with the NSIsNotNil value
transformer and set the correct placeholder options, but apparently
this doesn't work. I've tried various combinations of selection and
selectedObject with and without the NSIsNotNil value transformer, but
they don't change the view's state at all and most of the
combinations kick back nasty bindings error. I should also note that
the array controller that feeds the data to this tableview is itself
fed from coredata.
Anyone gotten something like this to work?
->Ben
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
<blachman...> -
Ben, check out the thread at <http://lists.apple.com/archives/Cocoa-
dev/2007/Aug/msg01021.html> for ideas. It's not precisely the same
problem discussed there, but it's essentially the same. The most
robust solution is given by mmalc, and there are also a few quick and
dirty hacks.
The NSArrayController's selection is a proxy object, so it won't
behave exactly as you expect, and you don't want to treat it as if it
were a normal object. In particular, I don't think it will ever be nil.
-Jeff
On Feb 17, 2008, at 2:10 AM, Ben Lachman wrote:
> I have a tableview who's enabled binding is bound to a
> NSArrayController (not the one that feeds it via its content
> binding). I'd like to be enabled when something is selected and
> disabled when it is not. So far I've been unable to find a
> suitable key to bind to on the array controller. It seems like you
> should just be able to bind to selection with the NSIsNotNil value
> transformer and set the correct placeholder options, but apparently
> this doesn't work. I've tried various combinations of selection
> and selectedObject with and without the NSIsNotNil value
> transformer, but they don't change the view's state at all and most
> of the combinations kick back nasty bindings error. I should also
> note that the array controller that feeds the data to this
> tableview is itself fed from coredata.
>
> Anyone gotten something like this to work?
>
> ->Ben
>
> --
> Ben Lachman
> Acacia Tree Software
>
> http://acaciatreesoftware.com
>
> <blachman...>
>
-
Thanks Jeff.
That solution worked perfectly for almost everything. I have several
other pieces of my UI that are all bound in this manner and they all
are enabled/disabled correctly. However the tableview itself is
seemingly still unaffected by it's enabled binding. In fact, even if
I stick in a vanilla table view and bind its enabled binding, it
doesn't seems to work, so now I'm wondering if the enabled binding
even works on table views. Can anyone verify this?
->Ben
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
<blachman...>
740.590.0009
On Feb 17, 2008, at 9:37 AM, Jeff Johnson wrote:
> Ben, check out the thread at <http://lists.apple.com/archives/Cocoa-> dev/2007/Aug/msg01021.html> for ideas. It's not precisely the same
> problem discussed there, but it's essentially the same. The most
> robust solution is given by mmalc, and there are also a few quick
> and dirty hacks.
>
> The NSArrayController's selection is a proxy object, so it won't
> behave exactly as you expect, and you don't want to treat it as if
> it were a normal object. In particular, I don't think it will ever
> be nil.
>
> -Jeff
>
>
> On Feb 17, 2008, at 2:10 AM, Ben Lachman wrote:
>
>> I have a tableview who's enabled binding is bound to a
>> NSArrayController (not the one that feeds it via its content
>> binding). I'd like to be enabled when something is selected and
>> disabled when it is not. So far I've been unable to find a
>> suitable key to bind to on the array controller. It seems like
>> you should just be able to bind to selection with the NSIsNotNil
>> value transformer and set the correct placeholder options, but
>> apparently this doesn't work. I've tried various combinations of
>> selection and selectedObject with and without the NSIsNotNil value
>> transformer, but they don't change the view's state at all and
>> most of the combinations kick back nasty bindings error. I should
>> also note that the array controller that feeds the data to this
>> tableview is itself fed from coredata.
>>
>> Anyone gotten something like this to work?
>>
>> ->Ben
>>
>> --
>> Ben Lachman
>> Acacia Tree Software
>>
>> http://acaciatreesoftware.com
>>
>> <blachman...>
>>
-
After banging my head against this for another couple hours I decided
just to do the enabling/disabling UI changes manually. It seems that
setEnable is being called just like it should be on the table view,
its just that the tableview isn't responding "correctly". So I now
stop accepting first responder, deselect any selected row, ignore
scrolling and turn off the scrollers, and draw the text of the cells
using a light gray text color when the textview is disabled. To do
this I have to subclass both the tableview and its enclosing
scrollview and define a delegate (to change the text color and ignore
selection of table rows when the table doesn't accept first
responder... not sure about that one). Seems like NSTableView should
do this for you when you disable it...
Anyone have any thoughts on this?
->Ben
--
Ben Lachman
Acacia Tree Software
http://acaciatreesoftware.com
<blachman...>
740.590.0009
On Feb 17, 2008, at 2:58 PM, Ben Lachman wrote:
> Thanks Jeff.>> Cocoa-dev/2007/Aug/msg01021.html> for ideas. It's not precisely
>
> That solution worked perfectly for almost everything. I have
> several other pieces of my UI that are all bound in this manner and
> they all are enabled/disabled correctly. However the tableview
> itself is seemingly still unaffected by it's enabled binding. In
> fact, even if I stick in a vanilla table view and bind its enabled
> binding, it doesn't seems to work, so now I'm wondering if the
> enabled binding even works on table views. Can anyone verify this?
>
> On Feb 17, 2008, at 9:37 AM, Jeff Johnson wrote:
>
>> Ben, check out the thread at <http://lists.apple.com/archives/
>> the same problem discussed there, but it's essentially the same.
>> The most robust solution is given by mmalc, and there are also a
>> few quick and dirty hacks.
>>
>> The NSArrayController's selection is a proxy object, so it won't
>> behave exactly as you expect, and you don't want to treat it as if
>> it were a normal object. In particular, I don't think it will
>> ever be nil.
>>
>> On Feb 17, 2008, at 2:10 AM, Ben Lachman wrote:
>>
>>> I have a tableview who's enabled binding is bound to a
>>> NSArrayController (not the one that feeds it via its content
>>> binding). I'd like to be enabled when something is selected and
>>> disabled when it is not. So far I've been unable to find a
>>> suitable key to bind to on the array controller. It seems like
>>> you should just be able to bind to selection with the NSIsNotNil
>>> value transformer and set the correct placeholder options, but
>>> apparently this doesn't work. I've tried various combinations of
>>> selection and selectedObject with and without the NSIsNotNil
>>> value transformer, but they don't change the view's state at all
>>> and most of the combinations kick back nasty bindings error. I
>>> should also note that the array controller that feeds the data to
>>> this tableview is itself fed from coredata.
>>>
>>> Anyone gotten something like this to work?
-
Ben,
I can confirm that setEnabled:NO on the tableview doesn't seem to
work right. So you may indeed have to take some 'extreme' measures
to get this to work. However, you can successfully get the cell text
color to change automatically if you set the enabled bindings on the
table columns.
-Jeff
On Feb 17, 2008, at 10:06 PM, Ben Lachman wrote:
> After banging my head against this for another couple hours I
> decided just to do the enabling/disabling UI changes manually. It
> seems that setEnable is being called just like it should be on the
> table view, its just that the tableview isn't responding
> "correctly". So I now stop accepting first responder, deselect any
> selected row, ignore scrolling and turn off the scrollers, and draw
> the text of the cells using a light gray text color when the
> textview is disabled. To do this I have to subclass both the
> tableview and its enclosing scrollview and define a delegate (to
> change the text color and ignore selection of table rows when the
> table doesn't accept first responder... not sure about that one).
> Seems like NSTableView should do this for you when you disable it...
>
> Anyone have any thoughts on this?
>
> ->Ben
> --
> Ben Lachman
> Acacia Tree Software
>
> http://acaciatreesoftware.com
>
> <blachman...>
> 740.590.0009
>



