Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!ucla-cs!ucla-se!edison!martin From: martin@edison.seas.ucla.edu (Kenneth Martin) Newsgroups: comp.sys.next Subject: Re: Help, please, on making connections in IB Message-ID: <2482@lee.SEAS.UCLA.EDU> Date: 23 Apr 91 00:48:33 GMT References: <2524@fornax.UUCP> Sender: news@SEAS.UCLA.EDU Distribution: na Organization: EE Dept., University of California, Los Angeles Lines: 59 > > The first problem is that I can't even create an object of > > class EntryField > > in Interface Builder. > > You're right, you can't instantiate your subclass, unless it is a > subclass of Object. I dont know why this restriction exists, but > there it is. > >Here are the classes which I can determine that IB will allow you to >instantiate: >1) Object >2) UserCreatedSubclassesOf:Object >3) List:Object >4) HashTable:Object >5) Sound:Object >6) Storage:Object >7) NXStringTable:HashTable:Object > >so clearly IB knows how to instantiate some of its (sub)classes but not others. Somewhere in the Next documentation, it states that subclasses of View can't be instantiated. You might try the following in using subclasses of View in IB. (I hope I get all the steps right). 1) Prepare the subclass.m and subclass.h files (i.e. MyTextField.m and MyTextField.h for this example) 2) Add them to the project using the project inspector 3) Double click the classes.h icon in the files window to get the classes browser 4) In the classes browser click the superclass (for example TextField in the directory under Control) 5) Using the 'Operations' pull-down menu in the classes browser, first select subclass, then name the new subclass, (for example MyTextField) and then using the pull-down menu again, parse the new class. 6) Prepare another subclass but this time of application. It might be called Coordinator.m and Coordinator.h. In this class, define some objects that will be your new View classes (eg. 'id mytextField' in Coordinator.h). Also include these files and tell the IB about them using the classes browser to subclass, name, and parse them. This class can and should be instantiated. 7) Drag in a CustomView from the Palettes window. 8) Using the Inspector and the Attributes submenu, rename the CustomView MyTextField. 9) Using the Inspector and the Miscellaneous submenu, rename the new view the same name used for the defined objects in Coordinator.m (i.e. mytextField). 10) Any special initialization code should be put in the initFrame method of your subclass or in the AppDidInit delegate method of Coordinator.m. If you use the former, make sure you call [super initFrame] in thennew initFrame method in MyTextField.m. If you use the latter, then a connection between File's Owner (in the files window) and Coordinator.m (with delegate selected as the outlet) is necessary. 11) Drag a connection between Coordinator.m and the renamed MyTextField view in the IB window (i.e. the view that used to be the CustomView). Make sure mytextField is selected as the outlet and then connect the View. If I haven't forgotten anything this should be it. I haven't tried this for TextField's but have used it for ScrollViews and Text objects. Good Luck. -Ken Martin (martin@icsl.ucla.edu)