diff --git a/0001-on b/0001-on index b83201a..82d68db 100644 --- a/0001-on +++ b/0001-on @@ -11,6 +11,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/0154-on.mouse_move b/0154-on.mouse_move new file mode 100644 index 0000000..9054468 --- /dev/null +++ b/0154-on.mouse_move @@ -0,0 +1,8 @@ +on.mouse_move = function(x,y, dx,dy, istouch) + if car.mousemoved then + call_protected(car.mousemoved, x,y, dx,dy, istouch) + end + if car.mouse_move then + call_protected(car.mouse_move, x,y, dx,dy, istouch) + end +end \ No newline at end of file diff --git a/main.lua b/main.lua index 217490b..e136f62 100644 --- a/main.lua +++ b/main.lua @@ -193,6 +193,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 327c109..2fcaa00 100644 --- a/reference.md +++ b/reference.md @@ -76,6 +76,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