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

Not hiding modal dialogs

In article <93May11.153540edt.144002@explorer.dgp.toronto.edu> Mark A. Tapia 
>I want to use the same window for ordinary operations and 
>occasionally as a modal-dialog. When the window is treated as
>a modal-dialog and close-on-return is nil, I want the window 
>to be the frontmost window after the modal-dialog.
>Here is an attempt based on Guillame Cartier's hide-window-mixin.
>Problem: While the window is frontmost at the end of the modal-dialog,
>it disappears for a short period of time.  How do I prevent it
>from temporarily disappearing?

The window isn't disappearing, it's just being sent to the rear for a
bit. (When you tried your sample there must have been another window
to obscure it.)

The problem is that the modal-dialog method for windows includes the
following code fragment to close the window when returning from the
modal-dialog (from the CD-ROM source):

  (if close-on-exit
     (window-close dialog)
     (progn (window-hide dialog)
            (set-window-layer dialog 9999)))

So in your code:

>(defmethod modal-dialog ((window my-window) &optional close-on-return
>  (let ((*force-hide* close-on-return))
>    (catch-cancel
>      (call-next-method window close-on-return event-hook)
>      (unless *force-hide*
>        (window-select window)))))

the call-next-method includes this step of first sending the window all 
the way to the rear before selecting it. 

One way around this might be to add a slot to your window class:

(defclass my-window (window)
  ((modal-p :initform nil :accessor modal-p))
  (:default-initargs :window-title "Modal demo"))

Then have modal-dialog set that slot:

(defmethod modal-dialog ((window my-window) &optional close-on-return
  (setf (modal-p window) t)
     (let ((*force-hide* close-on-return))
            (call-next-method window close-on-return event-hook)
	    (unless *force-hide*
	    (window-select window))))
  (setf (modal-p window) nil))

And then specialize set-window-layer:

(defmethod set-window-layer ((w my-window) new-layer 
			     &optional include-invisibles)
   (unless (modal-p w)

These changes seem to make your sometimes-modal window work the way
you want.

John Gersh                                      John_Gersh@jhuapl.edu
The Johns Hopkins University Applied Physics Laboratory
Johns Hopkins Rd., Laurel, MD 20723		       (301) 953-5503