From fbf99b040d11b0f583a2e4648604bc52b0fc5ba3 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Tue, 26 Dec 2023 08:28:23 -0800 Subject: [PATCH] wire up mouse move handler --- 0001-on | 1 + main.lua | 4 ++++ reference.md | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/0001-on b/0001-on index 7763ac0..fe81679 100644 --- a/0001-on +++ b/0001-on @@ -12,6 +12,7 @@ on = { -- on.focus -- on.mouse_press (see love.mousepressed) -- on.mouse_release (see love.mousereleased) + -- on.mouse_move (see love.mousemoved) -- on.mouse_wheel_move (see love.wheelmoved) -- on.keychord_press (see keychord.lua in this repo) -- on.text_input (see love.textinput) diff --git a/main.lua b/main.lua index 80d9e1d..7b809e9 100644 --- a/main.lua +++ b/main.lua @@ -191,6 +191,10 @@ function App.mousereleased(x,y, mouse_button) if on.mouse_release then on.mouse_release(x,y, mouse_button) end end +function App.mousemoved(x,y, dx,dy, istouch) + if on.mouse_move then on.mouse_move(x,y, dx,dy, istouch) end +end + function App.wheelmoved(dx,dy) if Mode == 'error' then return end Cursor_time = 0 -- ensure cursor is visible immediately after it moves diff --git a/reference.md b/reference.md index 4885846..b3b8621 100644 --- a/reference.md +++ b/reference.md @@ -85,6 +85,12 @@ two categories. button. Provides the same arguments as `on.mouse_press()` above. (Based on [LÖVE](https://love2d.org/wiki/love.mousereleased).) +* `on.mouse_move(x,y, dx,dy, istouch)` -- called when you move the mouse. + Provides in `x` and `y` the point on the screen at which the click occurred + and in `dx` and `dy` the amount moved since the previous call of + `mouse_move`. + (Based on [LÖVE](https://love2d.org/wiki/love.mousemoved).) + * `on.mouse_wheel_move(dx,dy)` -- called when you use the scroll wheel on a mouse that has it. Provides in `dx` and `dy` an indication of how fast the wheel is being scrolled. Positive values for `dx` indicate movement to the