NSFormCell for content other than text - objective-c

I am building a dynamic form in a Cocoa application and am planning to use the NSForm object to add entries to it from an array.
Some of the entries require a text input, but some require a boolean input (i.e. a dropdown list), and some even require a file input (i.e. a place to upload an image or a movie or sound file).
It seems that an NSFormCell is only equipped to handle text. My question is: Should I subclass NSFormCell and if so, what would be the best way to do this? Are there any better ways to do this?
Thank you for any help you can offer!

You might want to look into using an NSMatrix instead. From the NSForm documentation, NSForm is simply a subclass of NSMatrix with some convenience methods geared specifically towards creating a text form in a certain configuration.
NSMatrix will let you use any cell you want for any cell (using the putCell:atRow:column: method). Thus, you could have a two-column matrix, with the left column being composed entirely of text cells, and the right column being whatever type of cell you want.

As I haven't dealt much with NSForm myself (and haven't heard of NSFormCell before), I would personally use an NSMatrix for this task, adding the appropriate cells (NSTextFieldCell, NSButtonCell, NSPopUpButtonCell, etc) where necessary. Though I've not done this exactly in the same way as you describe before, I'm sure it should work.
-Steven Degutis
Edit: My goodness, looks like Matt Ball beat me to it. Thanks, Stackoverflow.com's-3-minute-limit-for-newbs! :D

Related

Is it possible to resize a DateTimePicker or MonthCalendar Control in VB.net

Essentially I want to re-size my dateTimePicker control to fit its parent container. I have tried to do this both through the Control Editor and programmatically but I simply cannot get the drop down calendar to expand at all. So 2 part question:
a) Is this even possible to do?
b) Is there an easy-to-implement solution to having a good looking calendar that fits its parent field? (i.e. using a data grid or something similar)
Any help or knowledge is greatly appreciated!!!
The size of both objects is fixed and defined by the size of its font. Thus you might change its size by affecting the font size. This works fine with DateTimePicker but does not seem to work with MonthCalendar. After a quick research I have found a pretty curious recommendation on the MSDN forum: "you can consider third party MonthCalendar controls to meet your requirement temporarily".
There are quite a few third-party options (after a really quick search I found this) or you might even create one by your own. I personally haven't ever had any problem with the in-built controls but if the size is so important for you I guess that you would have to search/develop something by your own.
Further recommendation: rely on WPF which does contain a resizable control (DatePicker). I want to highlight here that I don't like WPF at all and that thus this recommendation is because I don't see any other option (inside .NET).

How can I replicate a user created table?

This is a part of the iTunes smart playlist creation window; for my application I need to create something very similar to this:
The changes I'll be making would be the column that says artist would be integers (but still a pop up button), same with the second column. The third column would be text input like in the picture. I would like to keep the functionality of the "+" and "-" buttons but I don't have much use for the "..." button. Is there any easy way to recreate this? I need the user to be able to add as many or few fields as necessary.
Thanks in advance!
If you don't need to support 10.4, take a look at NSPredicateEditor. It should allow you to easily recreate iTunes' interface with the changes you describe. http://nvie.com/posts/nspredicateeditor-tutorial/ may be useful to help you get started.

Restricting input to NSTextViewCell inside NSMatrix

Objecive-C/Cocoa newbie...I have an NSMatrix composed of NSTextViewCells. I would like the user to be able to type at most one letter into each cell, have the letter upcased if necessary, and automatically tab to the next field.
It looks to me as if I can use an NSFormatter to do the upcasing, but I can't figure out how to get the auto-tabbing.
Is it just me, or is the available documentation in general less than wonderful? I've been reading Hillegass' book, which is great, but it only goes as far as it goes :)
Thanks.

Alternative to NSCollectionView in pre-OSX10.5, Cocotron?

NSCollectionView was introduced in OS X 10.5, and is not yet implemented in Cocotron.
I am trying to implement a small app that will allow creating properly packaged data files for an online service, which will then be uploaded by an administrator. More specifically, the user will create a collection of input and output data pairs, by dragging input and output files onto the window.
Currently the idea is that user drags a file, from the filename it's detected if it's the input or output filename (by default, input), and a view with icon and filename for input and output is added to collection view. Then, the second file is dropped on the "other" icon.
However, NSCollectionView does not appear in pre-10.5, and most of my users don't have Macs so I'll have to provide a Cocotron-built application. Not only that; I still don't fully understand KVC/KVO, and I really should understand everything that my code does. Hence, I need an alternative to NSCollectionView.
What alternative do I have to using NSCollectionView? (Any intuitive solution is appreciated, don't feel limited by the above description of my idea.)
To work with NSCollectionView, you need to not only understand KVC and KVO, but also Bindings.
There's code for an NSCollectionView clone that works on Tiger here.
I still don't fully understand KVC/KVO…
That's what the docs are for:
Key-Value Coding Programming Guide
Key-Value Observing Programming Guide
What alternative do I have to using NSCollectionView?
Make your own.

spell check textfield

I am trying to get a spellchecker to check spelling in a text field as the user types. I am well aware that browsers such as firefox have this feature for textfields (but this requires a user to manually enable it in the right click menu.
The ideal script Im looking for would accept an id as a parameter, since the id for the field I want to be checked cannot change.
Thanks
My suggestion would to look at a predictive text tool, similar to the tag-finder that SO uses where you have a dictionary, and as a term is typed, you do some kind of AJAX-y lookup to see if they're typing correctly.
Adding a new word would be similar to adding new tags on SO - if the predicted word is not picked, add it to your dictionary.
I'm sure there are others who have done a similar task, though - and this suggestion might be harder to implement than in sounds in my head.