From: Vladimir Zolotykh
Subject: with-dialog-timeout
Date: 
Message-ID: <opstz9stco4w83rv@algow.eurocom.od.ua>
Hi

Let me consider a very simple CLIM 2.2 dialog

(defun dlg (&optional (stream *query-io*))
   (accepting-values (stream :own-window t)
     (accept 'string :stream stream)))

If I call (dlg) the dialog's window will pop up and be hanging
(exposed or visible) until I as user click either of buttons. If I
won't it will be hanging forever. Is it possible to cancel this dialog
programmatically in the way that would be identical to pressing Cancel
button?

I tried to wrap accepting-values form with restart-case and then
invoking abort restart after some time. However I had to do that using
a separate process and it didn't work because the restart wasn't
visible.

If you know the solution I would appreciate if you give me a clue
about it.

Thanks in advance


-- 
Vladimir Zolotykh

From: Arthur Lemmens
Subject: Re: with-dialog-timeout
Date: 
Message-ID: <opst3wmti0k6vmsw@news.xs4all.nl>
Vladimir Zolotykh wrote:

> If I call (dlg) the dialog's window will pop up and be hanging
> (exposed or visible) until I as user click either of buttons. If I
> won't it will be hanging forever. Is it possible to cancel this dialog
> programmatically in the way that would be identical to pressing Cancel
> button?

If you can find the process that's taking care of your dialog window,
you can call ABORT in that process to cancel the dialog.

The best way to find this process may depend on the structure of your
application; below is a simple example:

(defvar *process* nil)

(defun dialog ()
  (setq *process* (clim-sys:current-process))
  (accepting-values (t :own-window t)
     (accept 'string :prompt "Text")))


Now you can cancel the dialog programmatically by using
PROCESS-INTERRUPT:

  (clim-sys:process-interrupt *process* 'abort)

 --
Arthur Lemmens
From: Vladimir Zolotykh
Subject: Re: with-dialog-timeout
Date: 
Message-ID: <opst3923vu4w83rv@algow.eurocom.od.ua>
On Mon, 18 Jul 2005 13:24:19 +0200, Arthur Lemmens <········@xs4all.nl>  
wrote:

> Now you can cancel the dialog programmatically by using
> PROCESS-INTERRUPT:

Thank you Arthur, it works fine

(defmacro with-dialog-timeout ((delay) &body body)
   (with-gensyms (proc timer)
     `(let* ((,proc (clim-sys:current-process))
	    (,timer (clim-utils::make-timer
		     :delay ,delay
		     :function #'(lambda (timer)
				   (declare (ignorable timer))
				   (clim-sys:process-interrupt ,proc 'abort)))))
        (clim-utils:add-timer ,timer)
        (unwind-protect
	   (progn ,@body)
	 (when ,timer
	   (clim-utils:delete-timer ,timer))))))


-- 
Vladimir Zolotykh