diff options
author | colin <colin@cicadas.surf> | 2024-12-14 08:36:23 -0800 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-12-14 08:36:23 -0800 |
commit | 3a2217263d581be9a7f629b10d75aa8e3d581890 (patch) | |
tree | 23f5f0a5449a06473aba2ec7914a3c2193823a10 /src/events | |
parent | 03cdbb6a15e130a012377ab8d54074b6864e3480 (diff) | |
parent | 8a51ba81c7df6b0b6dab7cf4b35b5ca084b653ba (diff) |
Merge branch 'refactor-with-def'
Diffstat (limited to 'src/events')
-rw-r--r-- | src/events/event-handler.lisp | 13 | ||||
-rw-r--r-- | src/events/listener.lisp | 49 |
2 files changed, 33 insertions, 29 deletions
diff --git a/src/events/event-handler.lisp b/src/events/event-handler.lisp index e9a26cd..62d8f54 100644 --- a/src/events/event-handler.lisp +++ b/src/events/event-handler.lisp @@ -2,10 +2,15 @@ (in-package #:wheelwork) - -(defclass/std event-handler () - ((event-type handler-function tag :ri)) - (:metaclass closer-mop:funcallable-standard-class)) +;; TODO: make event-type a type +(def:class event-handler () + ((event-type "A symbol naming the sort of event this function handles") + :required :ro) + ((tag "A tag identifying this handler uniquely. Used to remove anonymous handlers") + :ro :type (or null string) :initform nil) + ((handler-function "The actual function this handler calls") + :required :ro :type function) + :metaclass closer-mop:funcallable-standard-class) (defmethod initialize-instance :after ((eh event-handler) &key) (with-slots (handler-function) eh diff --git a/src/events/listener.lisp b/src/events/listener.lisp index e66afe2..75a1e1b 100644 --- a/src/events/listener.lisp +++ b/src/events/listener.lisp @@ -2,32 +2,31 @@ (in-package #:wheelwork) -(defclass/std listener () - ((keydown - keyup - mousedown - mouseup - mousemotion - mousewheel - focus - blur - perframe - :r :with :type (or null event-handler) :std nil) - (keydown-table - keyup-table - mousedown-table - mouseup-table - mousemotion-table - mousewheel-table - focus-table - blur-table - perframe-table - :static - :std (make-hash-table :synchronized t) - :doc "Keyed by DISPLAY-UNIT instance, holds an EVENT-HANDLER if +(def:class listener () + (keydown + keyup + mousedown + mouseup + mousemotion + mousewheel + focus + blur + perframe + :ro :prefix :type (or null event-handler) :initform nil) + (keydown-table + keyup-table + mousedown-table + mouseup-table + mousemotion-table + mousewheel-table + focus-table + blur-table + perframe-table + :noarg + :allocation :class + :initform (make-hash-table :synchronized t :test #'eq) + :documentation "Keyed by DISPLAY-UNIT instance, holds an EVENT-HANDLER if handler is defined for unit.")) - (:documentation "Event handlers per object. The static hash tables - are keyed by UNIT and hold Event-Handler instances.")) (defun listener-table-for (listener event-type) (ecase event-type |