Copyright ©1998 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H. All Rights Reserved.
5
Joy's interactive application inspector
This section explains how you can use Joy's application inspector to interactively explore the Yellow Box API.
Inspecting a Joy application
First bring up a Joy command window by double-clicking JoyTerminal.exe in the directory %NEXT_ROOT%\Local\Library\Joy\Examples\JoyTerminal\JoyTerminal.app where %NEXT_ROOT% is the path of your Yellow Box installation (e.g. C:\Next or C:\Apple). Drag down the divider bar just beyond the window's title bar to unhide the application inspector.
Figure 1: A Joy command window and its built-in application inspector.
This browser allows you to interactively experiment with the Yellow Box class hierarchy. As you can see, there are several root classes. Some of them are internal (non-documented) classes, NXProxy and Object are there for historical reasons (they used to be the NEXTSTEP root classes), NSObject and NSProxy are the only documented root classes of the Yellow Box class hierarchy.
Click on the NSObject class to see all its subclasses. The subclasses will show up in the second column of the browser:
Figure 2: NSObject and its many subclasses.
Scrolling shows that there are an overwhelming number of subclasses. The exact number is displayed in the title of the browser column. But don't be afraid, you do not have to study all of these classes. Some are needed only rarely, and others are internal classes that are not documented in the API (for example all the classes that with an underscore character). You can restrict the display to those classes which had instances when the browser window was loaded (we will show later how you can load the browser window into other applications). Drag the pop-up button on the top of the browser to Instantiated Subclasses:
Figure 3: Instantiated subclasses of NSObject.
You can now experiment with the browser to find some interesting classes. Most of the classes which make up the graphical user interface are subclasses of NSResponder. For example, you will find the NSBrowser class (whose only instance is the browser you are currently working with) or the NSApplication class (whose only instance is the application you are currently running). The NSWindow class is a direct subclass of NSResponder. The only instance of NSWindow is the window which displays the browser, the pop-up and the other graphical user interface elements. NSWindow also has an instantiated subclass, NSPanel:
Figure 4: NSPanel, a subclass of NSWindow.
If you switch the pop-up button back to Subclasses you can see that NSPanel has many subclasses (you may, for example, already have seen the Yellow Box's NSColorPanel in other applications). Switch the pop-up to Instances and select the All switch to the instances of NSPanel and all its subclasses. Select the Auto-update switch and select the menu item About JoyTerminal... in the Help menu to see a new instance appear. Click on that instance to see its instance methods.
Figure 5: The NSPanel instance and its methods.
Most of the instance methods of NSPanel are inherited from its superclasses. For example we will try to send NSWindow's center method to the NSPanel instance. Double-click the NSPanel instance and then double-click the center method. Press enter (you may want to move the panel to some other location first to see the effect).
Figure 6: Interactively sending a message to an object
You may also try to change the panel's title. Your command line should look similar to the following (the address of your NSPanel instance will be different):
tcl> NSPanel@0x215d30 setTitle: [@ "My new title"]
As you see, the info panel's title changes. As an exercise, try to close it without clicking its close button.
Inspecting non-Joy applications
Above you saw how to interact with objects in the JoyTerminal application. In the same manner you can interact with objects in any Yellow Box application. A Joy application normally has a Joy menu; if not one can simply be added in InterfaceBuilder. Non-Joy applications for which you have source can be linked with Joy as explained in the previous section . If it is a Yellow Box application you don't have the source code for, you can use Joy's Open with Joy feature:
1. | Double-click %NEXT_ROOT%\Local\Library\Joy\OpenWithJoy.app\OpenWithJoy.exe. |
2. | Use the open panel that comes up to choose any YellowBox application (select the .exe file inside the application's wrapper). This launches the application and adds a Joy menu with a Command Window... item to its menus. |
3. | Load the application inspector by selecting this item and dragging down the window's divider bar. |
The next section provides a more in-depth explanation of some of Joy's features (including the application inspector) and warns you of possible problems.