diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-24 08:03:24 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-24 08:03:24 -0500 |
commit | 2f0602913a02823092393b29a26992f61fafbdb4 (patch) | |
tree | 95192a3f4e5d1dd1374fe957197f91acf3f7c19d | |
parent | 4e0b8f9295e678f8d44476d1c602480dbd27388c (diff) |
[formatting]
-rw-r--r-- | wheelwork.lisp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/wheelwork.lisp b/wheelwork.lisp index 2968cc7..1aefd51 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -69,12 +69,22 @@ necessary." (:documentation "Event handlers per object. The static hash tables are keyed by UNIT and hold Event-Handler instances.")) - - (defclass/std interactive () ((listener :type (or null listener) :std nil :a)) (:documentation "Supplies an object with a listener slot.")) +(defun listener-table-for (listener event-type) + (ecase event-type + (keydown (keydown-table listener)) + (keyup (keyup-table listener)) + (mousedown (mousewheel-table listener)) + (mouseup (mouseup-table listener)) + (mousemotion (mousemotion-table listener)) + (mousewheel (mousewheel-table listener)) + (focus (focus-table listener)) + (blur (blur-table listener)) + (perframe (perframe-table listener)))) + (defun set-handler (interactive handler) (when (null (listener interactive)) (setf (listener interactive) (make-instance 'listener))) @@ -82,6 +92,7 @@ necessary." (slot-value (listener interactive) (event-type handler)) handler (gethash interactive (listener-table-for (listener interactive) (event-type handler))) handler)) + (defun unset-handler (interactive handler-or-event-type) "Handler can be an instance of EVENT-HANDLER or can be a symbol whose name is an event type." @@ -93,17 +104,7 @@ necessary." (setf (slot-value (listener interactive) event-type) nil) (remhash interactive (listener-table-for (listener interactive) event-type))))) -(defun listener-table-for (listener event-type) - (ecase event-type - (keydown (keydown-table listener)) - (keyup (keyup-table listener)) - (mousedown (mousewheel-table listener)) - (mouseup (mouseup-table listener)) - (mousemotion (mousemotion-table listener)) - (mousewheel (mousewheel-table listener)) - (focus (focus-table listener)) - (blur (blur-table listener)) - (perframe (perframe-table listener)))) + (defun should-listen-for-p (event-type &optional (app *application*)) (plusp (hash-table-count (listener-table-for (listener app) event-type)))) |