links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How can you transmit answers from one window to another?
Last updated at 4:28 pm UTC on 14 January 2006
Question: How can you transmit answers from one window to another?
Answer: From: How to save a part bin : Tuesday, January 06, 2004 2:13 AM
The situation: When a query window is executed, another window opens and displays the results the first window generates. How can the two windows transmit the arguments?

You do this:
In the first window, you collect the results.
Then you create a new object, and pass it the results to display.
You tell the newly created object to open a window.
It then displays those results.

Question: [First answer didn’t help...] I created two classes to represent the two windows: Query and Display. In the window "Query", there is a button "queryStart", and when it is pressed, another window "Display" opens.
   Display createWindow.?
   (Display open: aCollection)?.
In Display, a selector "display:aCollection" is used to display the results. however, a selector "createWindow" is used to construct the window frame. So the problem is that the two selectors can not be used together.
> Please tell me how to transmit the arguments as the window is created.

Answer: I guess I don't understand what you're doing. Are you using Squeak? Are you using Morphic? Are you using the Pluggable widgets?

Do the query and display things need to be windows? What's
	Display createWindow


MorphicGUIDemo.cs.gz is a quick demo showing how one window can open another. I am not doing this here just to show you how one window can open another. You probably don't want to have windows be their own models unless you don't have any more than one window displaying a particular thing at a time. Usually, you have a separate model class; changes to the model generate #changed messages: #someAspect' (where #someAspect is different for each part of the model.) These messages are listened to by the pluggable widgets. Here, however, the QueryWindow is its own model. This demo is also listed below, in case you would perfer to enter it yourself.

SystemWindow subclass: #QueryWindow
	instanceVariableNames: 'text1 text2'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'TwoWindows-Demo'

	"Create a new window (in this case, the same class) and open it."
	((QueryWindow text1: text1 text2: text2)
		setLabel: 'DisplayWindow';
		extent: self extent) openInWorld

	^Color blue muchLighter
	"I am my own model. Except for very simple situations this is not 
usually the case and there is a separate model."
	^self defaultBackgroundColor darker darker
text1: anObject
	text1 := anObject.
text2: anObject
	text2 := anObject.
	super initialize.
		minimumExtent: 400@400;
		setLabel: 'Query Window';
		addMorph: (PluggableTextMorph on: self text: #text1 accept: =#text1:) frame: (0@0 corner: 1@0.45);
		addMorph: (PluggableTextMorph on: self text: #text2 accept: =#text2:) frame: (0@0.45 corner: 1@0.9);
		addMorph: ((SimpleButtonMorph newWithLabel: 'Push Me') target: =self; actionSelector: #buttonPushed)
		frame: (0.45@0.9 corner: 0.55@1.0)
text1: s1 text2: s2
	"Initialize a new instance with the given texts"
	self text1: s1.
	self text2: s2.
	self initialize.

QueryWindow class methods 
	^(self text1: 'initial text1' text2: 'initial text2') 
       openInWorld; yourself
text1: stuff1 text2: stuff2
	^(self new)
		text1: stuff1 text2: stuff2;