binding contextual menu in NSTableView cell row
binding contextual menu in NSTableView cell row
- Subject: binding contextual menu in NSTableView cell row
- From: Julie Porter <email@hidden>
- Date: Mon, 14 Mar 2011 17:18:44 -0700
I am looking to replicate the user interface of the Mac OS7 abandonware
application MIDIGraphy.
Most of my experience has been with the QuckDraw toolbox (over 30
years?) I used to work for Apple Imaging and was one of the Postscript
Gurus on the Laserwriter team, so KV coding is second nature to me.
For the last decade or so I have been fighting the carbon/quartz moving
target. So a month or so back I started on the Cocoa tutorials.
(backwards postscript syntax?) I am finding that cocoa is now mature,
stable and finally has lived up to the promise of quick development time.
My current development platform is a mac mini ppc running leopard xcode
3.1.4.
I am able to graph a model of a midi file as a xcdatamodel.
Using interface builder I can import this model bound to a NSTableView.
By manipulating the bindings in interface builder, I can set the table
so each line (row) (a class and model called EventMIDI) is like this:
Time | Track |Channel | Status set (popup) | parameter text (contextual)
What I want is more like:
Time|Track|Channel|Status set (popup)|parameter set (contextual popup) |
parameter text (contextual)
To get the Status (popup) I define this in the model as a many to one
relation. I then run the app with a separate panel that lets me
populate status with the persistent names "Note","Control
Change","Meta", etc. A second value is numeric and represents the
actual midi status such as 9 for note, 11 for control change, 256 for
meta, etc. This is used to set the parameter text similar to the way
DepartmentsAndEmployees combines the first and last name through a Class
(called StatusMIDI in my example)
By manipulating the bindings on NSTableColum I can show both the status
"value" which is "Note" and the key "9" which is a number. Changing
the popup value changes the key in unison which is what I expect.
Since status (9) and channel(0) exist as values in the EventMIDI This
forms a parameter key. (which may be hidden from the user as they are
not always interested in looking at hex codes.)
To do this hiding (like in MIDIGraphy) the parameter text should be a
(contextual popup) and a contextual parameter text field. The status key
is the context.
Ideally I would like to keep this all in the persistent model view. In
my model I have arrays (sets) for the status contexts. IB included
array controllers for each of my sets. These sets are instatiated as
persistent by the user in preferences. This set will also used as a
filter predicate on the tabular data.
What I can not figure out is how to make a NSTableColumn of mutable
popup menus where the key based on the context of the status selected.
That somehow I should be able to take the selection from the status
array set and use this as a key on the parameter array for each line in
the event list. In my trial and error attempts to do this I usually get
a Bad_Access signal as I may be attempting to set the value to the key
rather than the selector index, which is what I think I need to bind to.
Much of the online code samples for overriding core data is dated and
does not use objective C2.0. So I am looking for a solution that works
with 10.5 and keeps my xcdatamodel somewhat clean. This model will
also be used to represent the piano roll view and mouse over tool tips
of the events. The non persistent parts of the model are populated and
saved to either a MIDISMF or MUSICXML file.
I am still a bit fuzzy on the Observer side of KVO. How the observer is
overridden. Especially things like In the DepartmentsAndEmployees
tutorial keyPathsForValuesAffecting<Key> which gave me no end of
headache. I kept adding an extra : between keyPathsForValuesAffecting
and the user defined property fullNameAndID in the tutorial. The
documentation on this looks like it came from mars. Dynamic API names
are weird.
I have been back and forth through the NSPersistentDocument core data
tutorial all week. I think the solution is simple, but probably must
be done programmaticly with a custom class, which uses the key of
status to indicate which contextual popup array (set) to load into the
cell row.
-julie
_______________________________________________
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