NSArrayController, NSMatrix and NSTrackModeMatrix
NSArrayController, NSMatrix and NSTrackModeMatrix
- Subject: NSArrayController, NSMatrix and NSTrackModeMatrix
- From: Angela Brett <email@hidden>
- Date: Mon, 25 Oct 2004 18:07:23 +1300
Hi,
I haven't had a chance to really play with bindings etc. until
recently, so be prepared for newbie misconceptions. Now that I'm
developing a new application, I'm trying to use bindings as much as
possible in order to get the hang of things. It's a fairly simple app
that would have been finished by now if I'd done it the old-fashioned
way, but the extra time I'm spending getting to grips with bindings
will surely speed things up in the long run.
One of the views (actually two of them, but that doesn't matter) is
an NSMatrix of NSTextFieldCells. The fields are not meant to be
editable or selectable, I'd like the NSMatrix to act just like it's
in Track mode, with no highlighting. I have bound it to an
NSArrayController, and then I add objects (just
NSMutableDictionaries, nothing fancy) to the NSArrayController from
an NSObject subclass which has the NSArrayController as an outlet.
Incidentally, I tried making it so that my object only held an
NSMutableArray which was either bound to the NSArrayController's
contentValue or connected to the NSArrayController's content outlet,
but couldn't get that to work... it's probably just as well since the
way I'm doing it now is actually slightly simpler.
Anyway, the problem I'm having is that I can't bind the content of
the NSMatrix when it's in Track mode. I can if it's in any of the
other modes, but then the cells highlight (if only momentarily) when
I click on them, which I don't want. If I put the NSMatrix in some
other mode in IB, set up the content binding, and then set it to
Track mode in IB, the content binding stays but when I run the app I
get an error saying that it's not KVC compliant for the key 'content'
(which explains why IB doesn't let me set the content binding of a
Track mode matrix.)
I can actually get around this by setting the matrix to some mode
other than Track in IB, and then setting the mode to Track
programmatically after I've added the right values to the array
controller. This is of course rather silly since it means I have to
have an outlet to the matrix in my object, and I have to change its
mode in and out of Track whenever I want to change the values.
I realise that NSArrayController probably isn't really meant for
this, since it has a whole lot of functionality for handling
selections and editing etc. which I'm not using... in fact it would
be much easier to get rid of the bindings and just add rows to the
NSMatrix manually. But as I said, I'm trying to use bindings as much
as possible for this little app just so I can get the hang of them,
so I'd like to know whether it is possible to have an NSMatrix fed by
an NSArrayController with no highlighting. How come setting one
property of the NSMatrix can influence whether it's KVC compliant for
a key, anyway?
--
Angela Brett
email@hidden
http://NSCoder.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden