From 2f0602913a02823092393b29a26992f61fafbdb4 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 24 Jun 2022 08:03:24 -0500 Subject: [formatting] --- wheelwork.lisp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'wheelwork.lisp') 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)))) -- cgit v1.2.3