Objective-Everything Release 5. Copyright ©1994-1998 by TipTop Software, Inc. All Rights Reserved.
Interactors can be used to access both "local" interpreters (interpreters executing in the same process where the interactor is executing) or "remote" interpreters (interpreters executing in a different, remote process).
To connect to a remote interpreter you can use robjpysh, robjtclsh, or robjperlsh from the command prompt. For example, to connect to the default ObjTcl interpreter running inside InterfaceBuilder (provided that ObjPalette and ObjTcl are loaded), simply type:
robjtclsh IBInterp
Now you can type, for example:
$NSApp showInfoPanel: [nil]
to make InterfaceBuilder show its info panel.
See robjpysh, robjtclsh, or robjperlsh in /Local/Developer/Executables for more detail; these executables are just simple scripts.
In InterfaceBuilder, you can directly configure an interactor using its attribute inspector to connect to a remote interpreter.
The ObjectWell class instances can be used as a drag source and a drop destination for arbitrary objects.
Run InterfaceBuilder, and load ObjCore and ObjTcl palette. Create a new application nib: click Document->NewApplication (Cmd-n). From the ObjCore palette drag two ObjectWell objects into the application window.
[Note that the ObjectWell object in the palette is actually an ObjectWell inside a NSBox. Hence to select an ObjectWell inside a box you have to double-click on it.]
Ctrl-drag from the left ObjectWell to the window title bar. Double-click "dragObject" in the connection inspector. As a result of this, the left ObjectWell will represent the window object.
From the ObjTcl palette drag the ObjTcl interpreter and drop it into the object suitcase. Ctr-drag from the interpreter to the right ObjectWell, and type "ow2" for global variable connection name.
Double click on ow2 in the connections inspector, click "Create" when you are asked whether to create action implementation. Type the following action implementation:
extend $ow2 { method -(void)action:(id)sender { NSRunAlertPanel [nil] "Dropped: [$self droppedObject]" [nil] [nil] [nil] interact } }
That is, when an object is dropped into the well, an alert panel will run and an interactor window will open.
Run the NIB file (Cmd-r). Drag from the left ObjectWell and drop into the right ObjectWell. Type:
tcl% [$ow2 droppedObject] setTitle: Foo...
in the interactor. The window title changes.
Now, drag from the left ObjectWell and drop directly into the interactor window. Continue typing: " setTitle: Bar..."
tcl% [objtcl::lookup {<NSWindow:0x...>}] setTitle: Bar...
Interactor windows accept object drops directly.
Note that object icons in ObjectiveBrowser are ObjectWells. Continuing on this example, type:
tcl% browse $NSApp
Click "_keyWindow" in the browser. Drag the window icon from the browser into the interactor window. Continue typing: " setTitle: Baz..."
tcl% [objtcl::lookup {<NSWindow:0x...>}] setTitle: Baz...
The interactor window title changes. Note that the interactor window was the key window when you typed "browse $NSApp".
Continuing further on this example, run another objtcl shell. Type:
$ objtclsh ObjTcl Shell 5.0a0. Copyright 1994-97 TipTop Software, Inc. [URL: http://www.tiptop.com/ Email: <info@tiptop.com>] % appkit::run interact
in a terminal shell, or simply run ObjShell.app and select Tcl.
Drag from the "_keyWindow" icon from Objective-Browser into the new interactor window. Continue typing: " setTitle: Remote!"
tcl% [objtcl::lookup {<NSDistantObject:0x...>}] setTitle: Remote!
The interactor window title in InterfaceBuilder changes. Drag the application icon from Objective-Browser (icon in the first browser column) into the new interactor. Continue typing: " showInfoPanel: [nil]"
tcl% [objtcl::lookup {<NSDistantObject:0x...>}] showInfoPanel: [nil]
Now, when you select back InterfaceBuilder, you will see the InterfaceBuilder info panel.
When you drag an ObjectWell object from one application into a receiving ObjectWell or interactor in another application, a Distributed-Objects connection gets automatically established between the applications. You can then simply send messages to the object in the remote application.
The TTReceptionist class is used as the underlying mechanism for vending objects to remote applications. TTReceptionist provides a "standard" way of vending objects (e.g., interpreters) over DO to other applications.
Here is a simple server implemented in ObjTcl which uses TTReceptionist to vend its interpreter:
set rv [TTReceptionist sharedInstance] $rv setConnectionName: [@ "TestConn"] $rv setObject: $interp forKey: [@ "ObjTclInterp"] # If you are not running from AppKit, you have to run explicitly: [NSRunLoop currentRunLoop] run
You can then use robjtclsh to connect to the interp: robjtclsh TestConn. See the TTReceptionist class documentation for more info.