[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Modal dialogs like the Finder
- To: firstname.lastname@example.org (Guillaume Cartier)
- Subject: Re: Modal dialogs like the Finder
- From: bill (Bill St. Clair)
- Date: Fri, 18 Oct 91 15:50:53
- Cc: email@example.com (Macintosh Common Lisp)
> Date: Fri, 18 Oct 91 12:57:18 -0400
> To: firstname.lastname@example.org (Macintosh Common Lisp)
> From: email@example.com (Guillaume Cartier)
> Subject: Modal dialogs like the Finder
> I need to do some computations while reporting the progress
> to the user (this is a fairly common task!).
> I would like the report window to be modal like the Finder's but
> calling "modal-dialog" does'nt return immediatly so I am stuck.
> Is there a way to get the behaviour I want?
Well, here's a start. This doesn't handle clicking in the close box correctly.
You need to set up a catch for the tag CCL::%MODAL-DIALOG to do that.
It also completely disables the menus. Doing this correctly modulo the
system 7 user interface guidelines is tricky.
(defmacro with-modal-report-dialog (dialog &body body)
(let ((thunk (gensym)))
`(let ((,thunk #'(lambda () ,@body)))
(declare (dynamic-extent ,thunk))
(call-with-modal-report-dialog ,dialog ,thunk))))
(defun call-with-modal-report-dialog (dialog thunk &optional close-on-exit)
#'(lambda (&aux (event *current-event*)
(what (rref event eventRecord.what)))
(unless (eq (window-layer dialog) 0)
(set-window-layer dialog 0))
(%stack-block ((wp 4))
(let* ((code (#_FindWindow (rref event eventRecord.where)
((eq code #$inMenubar))
((%ptr-eql (wptr dialog) (%get-ptr wp))
(return-from eventhook nil))))))
(t (return-from eventhook nil)))
(set-window-layer dialog 0)