Re: Instantiating NSCells in Interface Builder
Re: Instantiating NSCells in Interface Builder
- Subject: Re: Instantiating NSCells in Interface Builder
- From: Daniel Zitter <email@hidden>
- Date: Wed, 4 Jun 2003 08:16:34 -0700
Date: Wed, 4 Jun 2003 17:44:12 +1000
Subject: Instantiating NSCells in Interface Builder
From: Pete Yandell <email@hidden>
To: email@hidden
I've a feeling that this is a really dumb question, but is there a way
to instantiate an NSButtonCell (or other arbitrary class for that
matter) in Interface Builder?
I thought it would just be a case of going to the Classes tab,
selecting NSButtonCell and choosing Instantiate from the Classes menu.
Unfortunately most of the available classes leave the Instantiate meny
greyed out. Why is that? Am I missing something obvious?
Pete Yandell
http://pete.yandell.com/
Since cells aren't particularly useful without their associated
controls, directly instantiating a cell isn't the way to go in
Interface Builder. (This must be documented somewhere, but I cannot
find it at the moment.)
Instead, you create the control you desire (a button, or a matrix of
buttons), then select the cell contained therein, and use the Custom
Class view of the inspector panel to set the cell class the control
should use. (If you desire your own cell subclass, you must teach IB
about that class before you can assign it as the custom class of a
control.)
One caveat: You cannot access the cell of a button which has just been
dragged off of IB's "Cocoa-Views" palette. Option-drag the button to
create additional buttons. This magically transforms the NSButton into
an NSMatrix of button cells. You may then double-click the matrix to
access the cells of the matrix. If you really only desired a single
button cell, you can then option-drag the matrix to have just one cell.
These contortions can seem a little roundabout and it may be troubling
to have a matrix when you really just wanted a button, but most of the
time this difference is academic: the user won't know the difference.
(Of course, your code and IB will know the difference, so you won't
want to strongly-type any outlets which connect to your matrix as type
NSButton *.)
Cheers,
Dan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.