wire up touch handlers

I have no idea how events like on.touchpressed were working until now.
This still seems useful to add on.touch_press.
This commit is contained in:
Kartik K. Agaram 2023-12-26 09:22:19 -08:00
parent 4241270cf2
commit efd7f15a2f
3 changed files with 34 additions and 0 deletions

View File

@ -13,6 +13,9 @@ on = {
-- on.mouse_release (see love.mousereleased)
-- on.mouse_move (see love.mousemoved)
-- on.mouse_wheel_move (see love.wheelmoved)
-- on.touch_press (see love.touchpressed)
-- on.touch_release (see love.touchreleased)
-- on.touch_move (see love.touchmoved)
-- on.keychord_press (see keychord.lua in this repo)
-- on.text_input (see love.textinput)
-- on.key_release (see love.keyreleased)

View File

@ -200,6 +200,22 @@ function App.wheelmoved(dx,dy)
if on.mouse_wheel_move then on.mouse_wheel_move(dx,dy) end
end
function App.touchpressed(x,y, dx,dy, pressure)
if Mode == 'error' then return end
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.touch_press then on.touch_press(x,y, dx,dy, pressure) end
end
function App.touchreleased(x,y, dx,dy, pressure)
if Mode == 'error' then return end
Cursor_time = 0 -- ensure cursor is visible immediately after it moves
if on.touch_release then on.touch_release(x,y, dx,dy, pressure) end
end
function App.touchmoved(x,y, dx,dy, pressure)
if on.touch_move then on.touch_move(x,y, dx,dy, pressure) end
end
function App.focus(in_focus)
if Mode == 'error' then return end
if in_focus then

View File

@ -88,6 +88,21 @@ two categories.
right. Positive values for `dy` indicate upward movement.
(Based on [LÖVE](https://love2d.org/wiki/love.wheelmoved).)
* `on.touch_press(x,y, dx,dy, pressure)` -- called when you touch a
multi-touch screen. Provides in `x` and `y` the point on the screen at which
the touch occurred.
(Based on [LÖVE](https://love2d.org/wiki/love.touchpressed).)
* `on.touch_release(x,y, dx,dy, pressure)` -- called when you release a touch.
Provides the same arguments as `on.touch_press()` above.
(Based on [LÖVE](https://love2d.org/wiki/love.touchreleased).)
* `on.touch_move(x,y, dx,dy, pressure)` -- called when you move any finger on
a multi-touch screen. Provides the same arguments as `on.touch_press()`
above, with `dx` and `dy` containing the amount moved since the previous
call to `touch_move`.
(Based on [LÖVE](https://love2d.org/wiki/love.touchmoved).)
* `on.keychord_press(chord, key)` -- called when you press a key-combination.
Provides in `key` a string name for the key most recently pressed ([valid
values](https://love2d.org/wiki/KeyConstant)). Provides in `chord` a