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

Not hiding modal dialogs



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?

Thanks,

mark
 
(in-package ccl)
(defparameter *force-hide* t)

(defclass my-window (window) 
  ()
  (:default-initargs
    :window-title "Modal demo"))
(defmethod initialize-instance ((window my-window) &rest initargs)
  (apply #'call-next-method window initargs)
  (add-subviews window
                (make-instance
                'button-dialog-item
                :view-position   #@(10 10)
                :view-size #@(62 16)
                :dialog-item-text "OK"
                :view-nick-name 'ok
                :dialog-item-action #'(lambda (item)
                                        item
                                        (return-from-modal-dialog t))
                :dialog-item-enabled-p nil
                :default-button t)))

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

(defmethod window-hide ((window my-window))
  (if *force-hide*
    (call-next-method window)
    (progn
    (window-select window)
    (dialog-item-disable (view-named 'ok window)))))

#|
(defvar *that* (make-instance 'my-window))
(progn
  (window-select *that*)
  (dialog-item-enable (view-named 'ok *that*))
  (modal-dialog *that* nil))

(window-close *that*)
(makunbound '*that*)
|#