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

y-or-n-dialog from window-c



REGARDING                y-or-n-dialog from window-close-event-handler
Some time ago I did sent the following message but i didn't get any replies.
I'm writing an application that needs swapping the menubar and dialogs like the
ones in the example, and would really like to understand why the menubar is
(mostly) disabled. Even if I'm doing something completely stupid, please fill
me in.

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 in the *default-menubar* 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

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

(defparameter *MYWINDOW-MENUBAR*
  (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-MENUBAR*)
  (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))
|#