Custom buttons & nib2cib in Cappuccino
nib2cib is an invaluable tool when creating web apps using Cappuccino because it allows you to create your UI using Interface builder.
If you want to use a subclass of CPButton (and I would image this holds true for other CPControl subclasses), you’ll may run into a couple of problems. First, if you place a NSButton on the view then change it’s class to your custom class name, you’ll find that nib2cib won’t display your custom button. Alternative, if you place a NSView on the view, nib2cib will display your button but when you try to create connection the sent perform action to a class that could receive that connection, you’ll find that connection missing because it does not exist for NSView.
One solution is to place on the view an instance of NSControl. On the view in nib2cib it will appear as an instance of NSView so you can size it to the proper dimensions, but because it is NSControl you can also connect the send action to the appropriate receiver.
After you have connected the action, THEN you can change the class name of the object from NSControl to your custom class name. IB will give you a warning, but you’ll find that after you run nib2cib and refresh your browser, the button will work as expected
If your custom button code sets images to the button such as setting the bezel-color value to a custom image, you will need to get nib2cib to find those Resource. To do that you must use the -R switch.
For example (Assuming I’m in the Resources directory):
nib2cib myAwesomeWindow.xib -R .
The “.” at the end instructs nib2cib to use the current directory to check for resources.