[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Waiting for Interaction



We have a complex interaction requirement that we can't figure out how to
handle in MCL.  Normally, an interface is set up so that all event handling is
asynchronous and dispatched from the CLOS various event handlers.  However, 
it is sometimes required to have an application wait for an interaction to
be completed.

Under X/11, we just invoke a second recursive xlib:event-case procedure and 
then do a throw from inside it when we are ready to exit the nested loop
(see code below).  This allows the exit from the recursive call
to be arbitrary levels down.  There is a catch around the
nested xlib:event-case.  For example: When a
button is pressed, it might call pop up a dialog box and then call 
Wait-Interaction-Complete.  The "OK" of the dialog box would call 
Interaction-Complete.  Note that the chief advantage of this is that the
Wait-Interaction-Complete DOES NOT RETURN until the dialog box is finished, 
and then it can return the value computed in the dialog box.
Note also that the Wait-Interaction-Complete is being called
(indirectly) from an event handler for the mouse button.  Sample code:

;;; Function for X/11 to wait for user to complete a nested interaction.  
;;; How can this be implemented under mcl?
(defun Wait-Interaction-Complete ()
      (unwind-protect
	 (setq val (catch 'exit-wait-interaction-complete
		     (xlib:event-case ....)))
      ;; unwind-protect exit
      (progn
	;; recover
	...
       ))

(defun Interaction-Complete (&optional val)
  "Call this to exit the Wait-Interaction-Complete procedure.  Typically,
   Interaction-Complete would be called from a :selection-function or
   :final-function"
 (throw 'exit-wait-interaction-complete val))

THE QUESTION:
*** Is there any way to do this kind of thing in MCL?  We can't use the
*** built-in modal dialog box stuff.  It is my understanding that you cannot
*** wait for any further events while inside an event handler, and also since
*** there aren't multiple processes, there doesn't seem to be any way to 
*** cause a procedure to wait for some interaction to be completed.

*** ANY IDEAS APPRECIATED!

Thanks,

Brad A. Myers
Computer Science Department
Carnegie Mellon University
5000 Forbes Avenue
Pittsburgh, PA  15213-3891
(412) 268-5150
FAX: (412) 681-5739
bam@a.gp.cs.cmu.edu