From 129e6e79c27bff4f7f3cc07aa22028d7ede6f3bd Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 24 Jun 2022 09:17:44 -0500 Subject: [add] mousebutton up events and handlers --- wheelwork.lisp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/wheelwork.lisp b/wheelwork.lisp index 0fdfdf4..6cebb66 100644 --- a/wheelwork.lisp +++ b/wheelwork.lisp @@ -437,11 +437,20 @@ give focus to whatever was clicked." (when-let (handler (get-handler-for target 'mousedown)) (funcall handler target x y clicks button wx wy))))) +(defun eventloop-mousebuttonup (app wx wy clicks button) + (when (should-listen-for-p 'mouseup app) + (destructuring-bind (x y) (screen-to-world wx wy) + (when-let* ((target (or (unit-under app x y) + app)) + (handler (get-handler-for target 'mouseup))) + (funcall handler target x y clicks button wx wy))))) + (defun eventloop-mousemotion (app wx wy wxrel wyrel state) (when (should-listen-for-p 'mousemotion app) (destructuring-bind (x y) (screen-to-world wx wy) (destructuring-bind (xrel yrel) (screen-to-world wxrel wyrel) - (when-let* ((target (unit-under app x y)) + (when-let* ((target (or (unit-under app x y) + app)) (handler (get-handler-for target 'mousemotion))) (funcall handler target x y xrel yrel state wx wy wxrel wyrel)))))) @@ -451,6 +460,7 @@ give focus to whatever was clicked." (handler (get-handler-for focus 'mousewheel))) (funcall handler focus wx wy dir)))) + (defun eventloop (app) (sdl2:with-event-loop (:method :poll) (:mousebuttondown @@ -459,6 +469,9 @@ give focus to whatever was clicked." (:mousemotion (:x x :y y :xrel xrel :yrel yrel :state state) (eventloop-mousemotion app x y xrel yrel state)) + (:mousebuttonup + (:x x :y y :clicks clicks :button button) + (eventloop-mousebuttonup app x y clicks button)) (:keydown (:keysym keysym) (eventloop-keydown app keysym)) -- cgit v1.2.3