aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-06-24 09:17:44 -0500
committerColin Okay <colin@cicadas.surf>2022-06-24 09:17:44 -0500
commit129e6e79c27bff4f7f3cc07aa22028d7ede6f3bd (patch)
tree9a512c591dbf0cdf40bed60915967502a9fccf78
parent59788c797fe6eb693713782022ddc050fb9e23b9 (diff)
[add] mousebutton up events and handlers
-rw-r--r--wheelwork.lisp15
1 files changed, 14 insertions, 1 deletions
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))