ftp.nice.ch/peanuts/GeneralData/Usenet/news/1989/CSN-89.tar.gz#/comp-sys-next/1989/Sep/Some-elementary-questions...

This is Some-elementary-questions... in view mode; [Up]


Date: Sun 22-Sep-1989 20:39:30 From: Unknown Subject: Some elementary questions... Can anyone answer a few elementary questions? I'm just now learning the NeXT development environment, specifically the Interface Builder. I thought a good project would be to add a scrollview to the RPN Calculator application that comes in the Examples. The scrollview would display the current contents of the stack so, for example, the user could view all twenty elements on the stack if it was full. I have moved a scrollview from the palettes window into the main application window but I don't know how to connect it to the Calculator object so that some sort of update message is sent to the scrollview at every operation that changes the stack. I think the connection involves some sort of control object, but I'm not sure how to work this into the IB. Some other simple questions on the Calculator example: 1. What object sends the setAWindow: and setAViewer: messages to the Calculator object? I'm trying to see how these are connected. 2. What is the parameter anObject to these methods and where does it come from? Sorry again to tie up bandwidth with easy questions, but I'm really stuck. CODELLI,DAVID KARL Georgia Institute of Technology, Atlanta Georgia, 30332 >From: hall@eclipse.stanford.edu (Keith Hall)
Date: Sun 23-Sep-1989 02:19:56 From: Unknown Subject: Re: Some elementary questions... In article <2003@hydra.gatech.EDU> David K. Codelli writes: >I thought a good project would be to add a scrollview to the >RPN Calculator application that comes in the Examples. The >scrollview would display the current contents of the stack so, >for example, the user could view all twenty elements on the stack >if it was full. I have moved a scrollview from the palettes window >into the main application window but I don't know how to >connect it to the Calculator object so that some sort of update message >is sent to the scrollview at every operation that changes the stack. >I think the connection involves some sort of control object, but >I'm not sure how to work this into the IB. You probably want the Calculator brain (implemented in the Calculator.m file) to have a handle on the ScrollView. The best way to do this is to use the outlets mechanism and do it the same way the Calculator object gets an handle on its output display through the aViewer outlet. Outlet variables are simply "id"s (pointers to objects) that are assigned through Interface Builder. First thing you will need to do is give Calculator a new outlet --- add it to Calculator.h, right where the outlets "viewer" and "aWindow" are declared. Call it stackViewer. Outlets are assigned when the .nib file is being read in. If an object has an outlet named "foo," it should also implement a method named "setFoo:" which takes one argument. This argument is the object outlet variable foo will point to. Thus setFoo: would look like: - setFoo:anObject {foo = anObject; return self;} While the .nib file is being loaded, the setFoo: method will be called with anObject bound to the appropriate object. Thus your object's foo instance variable will point to it. If you are creating your class from within Interface Builder, from ground up, Interface Builder will generate the above code for you for all your outlets, when you "unparse" your class. Interface Builder is not able to go add stuff to an existing class file, so for Calculator, it's probably best to add the setStackViewer: method to your Calculator.m and Calculator.h files by hand. Follow the example of setViewer:, which looks just like setFoo: above. There's nothing stopping you from doing fancier things in your outlet initialization methods; for instance, the setAWindow: method in Calculator.m sets the window's delegate as well as assigning aWindow. Anyway, this should get you in the right path for using outlets. After adding the stackViewer outlet to Calculator, you can go ahead & connect it to your ScrollView object though InterfaceBuilder. Now, at runtime, when your calculator's setStackViewer: method is invoked, the argument anObject will point to the ScrollView object. ScrollView objects do not come with anything in them; you normally have to create and add a document inside the ScrollView. However, the ScrollView object that is visible in the IB palette comes with an instance of Text object already installed; this Text object is available through the docView method of the ScrollView class. Considering you want your calculator to be talking to the Text object and not the ScrollView, you might want to actually assign stackViewer to [anObject docView] and not just anObject. Good luck with the above, and have fun! Ali Ozer, NeXT Developer Support Ali_Ozer@NeXT.com >From: greid@adobe.com (Glenn Reid)

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Marcel Waldvogel and Netfuture.ch.