I am trying to create a parameter, current-frame, that allows me to access the &#39;current frame&#39; in a multiple frame environment.&nbsp; In this case, the &#39;current frame&#39; is the one under which the user initiated the action which has caused a particular function to run.&nbsp; A very simple example might be as follows:<br>
<br><span style="font-family: courier new,monospace;">#lang scheme/gui</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define current-frame</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (make-parameter #f))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define my-frame%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (class frame%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (super-instantiate ())</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (field (text-field</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (instantiate text-field%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Press test button to update:&quot; this))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (instantiate button%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Clear&quot; this)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (callback</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (lambda (b e)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (send text-field set-value &quot;&quot;))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (instantiate button%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Test&quot; this)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (callback</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (lambda (b e)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (update-text-field))))))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define (update-text-field)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (send (get-field text-field (current-frame))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; set-value (send (current-frame) get-label)))</span><br style="font-family: courier new,monospace;">
<br>The update-text-field function will set the value of the text-field field in the &#39;current frame&#39; to the label of the &#39;current frame&#39;.&nbsp; When update-text-field is invoked, I want the value of the current-frame parameter to be the frame where the user clicked the Test button.&nbsp; So, the behavior I want is for the text-field in the frame in which the Test button is clicked to be updated with the label of that frame. [Yes, in this case it would be easy to just pass the frame to update-text-field or any of several other trivial solutions.&nbsp; But, bear with me.]<br>
<br>I have tried various combinations of parameterize and current-frame, with no success.&nbsp; For example:<br><br><span style="font-family: courier new,monospace;">(parameterize ((current-frame (instantiate my-frame%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Frame 1&quot;))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; (send (current-frame) show #t)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (update-text-field))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(parameterize ((current-eventspace (make-eventspace)))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (parameterize ((current-frame (instantiate my-frame%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Frame 2&quot;))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (send (current-frame) show #t)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (update-text-field)))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(parameterize ((current-eventspace (make-eventspace)))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; (let ((frame-3 (instantiate my-frame%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Frame 3&quot;))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (current-frame frame-3)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (send (current-frame) show #t)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; (update-text-field)))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(let ((frame-4 (instantiate my-frame%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Frame 4&quot;))))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (current-frame frame-4)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; (send (current-frame) show #t)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (update-text-field))</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(let ((frame-5 (instantiate my-frame%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&quot;Frame 5&quot;))))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; (current-frame frame-5)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp; (send (current-frame) show #t)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; (update-text-field))</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">If you evaluate all of these, then Frame 1, Frame 4, and Frame 5 all share a common eventspace.&nbsp; Clicking the Test button on any of them will result in &quot;Frame 5&quot; being written in the text-field in Frame 5.&nbsp; Clicking the Text button on either Frame 2 or Frame 3, which should be running in their own eventspaces, both give an error &quot;get-field: expected an object, got #f&quot;.&nbsp; In all cases, the hard-coded calls to update-text-field that are lexically within the scope (and eventspace) that instantiated the frame work as expected.<br>
<br>I assume the problem is with my mental model of parameters and eventspaces.&nbsp; I had assumed that each eventspace would have, in addition to its event queues, etc,&nbsp; its own execution thread, and copies of any parameters.&nbsp; Since it allows me to parameterize or set the current-frame in a new eventspace, I assume the eventspace &#39;knows about&#39; my current-frame parameter.&nbsp; What I don&#39;t understand is why a call to update-text-field by a frame that I think is running under &#39;new&#39; eventspace doesn&#39;t get a value for the current-frame parameter.&nbsp; So, I understand the behavior of Frames 1, 4, and 5 - or at least they fit my (probably flawed) mental model.&nbsp; But, I don&#39;t understand the behavior of Frames 2 and 3, which seems like they would work if my mental model were correct.<br>
<br>I tried to use get-top-level-focus-window, but it doesn&#39;t work in my case.&nbsp; This is an analysis application where some functions are very long running and the focus window at the time something is running isn&#39;t necessarily what I was thinking of as the &#39;current frame&#39;.<br>
<br>As an aside, I am basically trying to the replicate the functionality of the *application-frame* (dynamically-scoped) global variable in CLIM.<br>