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

y-or-n-dialog en menus



REGARDING                y-or-n-dialog en menus
In the following code when clicking in the window-close-box of a window of the
class wywindow a yes-or-no-dialog is popped up. After pushing the yes-button or
the no-button some menus are disabled.  Can anyone explain this behaviour to
me? 

Thanks in advance
Andre Koehorst
Research Institute for Knowledge Systems
Maastricht, the Netherlands
email: andre@riks.nl (why aren't all adresses that simple?)

;;; file menu-test.lisp
(defclass mywindow (window)
  (
  )
  (:documentation
"")
  )

(defparameter *MYWINDOW-MENU*
  (list (MAKE-INSTANCE 'MENU
    :MENU-TITLE
    "Wy Window"
    :MENU-ITEMS
    (LIST (MAKE-INSTANCE 'MENU-ITEM 
            :MENU-ITEM-TITLE "New")
          (MAKE-INSTANCE 'MENU-ITEM
            :MENU-ITEM-TITLE "-"
            :DISABLED  T)
          (MAKE-INSTANCE 'MENU-ITEM 
            :MENU-ITEM-TITLE "Open")
          (MAKE-INSTANCE 'MENU-ITEM
            :MENU-ITEM-TITLE "Close")
          (MAKE-INSTANCE 'MENU-ITEM
            :MENU-ITEM-TITLE "-"
            :DISABLED T)
          (MAKE-INSTANCE 'MENU-ITEM 
            :MENU-ITEM-TITLE "Save")
          (MAKE-INSTANCE 'MENU-ITEM
            :MENU-ITEM-TITLE "Save As...")
          (MAKE-INSTANCE 'MENU-ITEM
            :MENU-ITEM-TITLE "Revert")
          ))))

(defmethod view-activate-event-handler ((window mywindow))
  (set-menubar *mywindow-menu*)
  (call-next-method))

(defmethod view-deactivate-event-handler ((window mywindow))
  (set-menubar *default-menubar*)
  (call-next-method))

(defmethod close-mywin ((window mywindow))
  (let ((save-changes (y-or-n-dialog "Save changes?")))
    (when save-changes (format t "~%Saving"))))
  
(defmethod window-close-event-handler ((window mywindow))
  (close-mywin window)
  (call-next-method)
  )

#|
(make-instance 'mywindow)
(mapcar #'menu-enable (menubar))
|#