diff options
author | Colin Okay <colin@cicadas.surf> | 2022-06-27 18:39:38 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-06-27 18:39:38 -0500 |
commit | f311a9c510e4c54fb6cfaac2c3dc9681b6804b3a (patch) | |
tree | 43d9badbdd1f16f36cfd117e1cabd8de43f6d9d4 /examples | |
parent | a1d9b923a8d4a1d362aa41fcf7708fe64158d55f (diff) |
[add] can now hold many event handlers on a single listener
Diffstat (limited to 'examples')
-rw-r--r-- | examples/03-font-render.lisp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/examples/03-font-render.lisp b/examples/03-font-render.lisp index e47341b..60ffcf2 100644 --- a/examples/03-font-render.lisp +++ b/examples/03-font-render.lisp @@ -26,6 +26,24 @@ -800)) (incf (ww::unit-x target) 5))) +(defvar *spin-table* (make-hash-table :synchronized t)) + +(ww::defhandler spin + (ww::on-perframe () + (let ((rot + (gethash target *spin-table* 0.0))) + (if (< rot (* 8 pi)) + (setf + (gethash target *spin-table*) (+ rot 0.2) + (ww::unit-rotation target) rot) + (progn + (ww::remove-handler target #'spin) + (remhash target *spin-table*)))))) + +(ww::defhandler twirl-on-click + (ww::on-mousedown () + (ww::add-handler target #'spin))) + (defmethod ww::boot ((app font-display)) (let ((hello (make-instance @@ -39,10 +57,7 @@ (ww::unit-y hello) 400) (ww::add-handler hello #'marquee) (ww::add-handler hello #'change-text-color) - (ww::add-handler hello - (ww::on-mousedown () - (format t "I Was Clicked at ~a,~a!~%" - x y))) + (ww::add-handler hello #'twirl-on-click) (ww::refocus-on hello) (ww::add-unit app hello))) |