NSFormCell for content other than text
I am creating a dynamic form in a Cocoa application and am planning to use an NSForm object to add records to it from an array.
Some of the entries require text input, but some require boolean input (i.e. dropdown) and some even require file input (i.e. space to load an image or movie or sound file).
It seems like NSFormCell is only for text processing. My question is, should I subclass NSFormCell, and if so, what would be the best way to do it? Are there any better ways to do this?
Thanks for any help you can offer!
source to share
You might want to explore NSMatrix
. From the documentation NSForm
NSForm
is just a subclass NSMatrix
with some convenience methods specifically designed to create a text form in a specific configuration.
NSMatrix
will allow you to use any cell you want for any cell (using a method putCell:atRow:column:
). Thus, you can have a two-column matrix where the left column is entirely text cells and the right column is whatever type of cell you want.
source to share
Since I didn't know much about NSForm (and hadn't heard of NSFormCell before), I personally would use NSMatrix for this task, adding appropriate cells (NSTextFieldCell, NSButtonCell, NSPopUpButtonCell, etc.) where necessary. While I didn't do it exactly like you described earlier, I'm pretty sure it should work.
-Steven Degutis
Edit: Oh my God, looks like Matt Ball beat me up. Thanks, Stackoverflow.com's-3-minute-limit-for-newbs !: D
source to share