diff options
-rw-r--r-- | gui/menus.lisp | 3 | ||||
-rw-r--r-- | src/interactive/interactive.lisp | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gui/menus.lisp b/gui/menus.lisp index 6b3feb9..25abd7b 100644 --- a/gui/menus.lisp +++ b/gui/menus.lisp @@ -9,6 +9,9 @@ :doc "The item that is focused in this menu, if any.") (region :std (error "Menus require an explicit region")))) +(defmethod cleanup :after ((menu menu)) + (loop for item in (menu-items menu) do (cleanup item))) + (defmethod initialize-instance :after ((menu menu) &key) (with-slots (base-width base-height region) menu (setf base-width (width region) diff --git a/src/interactive/interactive.lisp b/src/interactive/interactive.lisp index ceacf1b..11bc5ca 100644 --- a/src/interactive/interactive.lisp +++ b/src/interactive/interactive.lisp @@ -7,6 +7,14 @@ (focusablep :std t :doc "Whether or not this object can receive application focus.")) (:documentation "Supplies an object with a listener slot.")) +(defun remove-all-handlers (interactive) + (loop + for type in '(keydown keyup mousedown mouseup mousemotion mousewheel focus blur perframe) + do (remove-handler interactive type))) + +(defmethod cleanup :after ((ob interactive)) + (remove-all-handlers ob)) + (defun add-handler (interactive handler) "Adds HANDLER to INTERACTIVE. HANDLER is an instance of WHEELWORK::EVENT-HANDLER, as most readily constructed by using the |