Mouse versus Touch
Posted: Fri Mar 30, 2018 3:32 pm
Have written a simple function to detect mouse interaction with a given area of the screen.
Works exacted as expected when using the mouse.
However, I found that it also works for Touch EXCEPT that if I touch within the area, it indicates that I am still hovering over it even after I remove my finger.
Is this expected behavior?
Is there a way to turn off hover when the touch is no longer in contact with the screen?
Tried setting hover, mx and my to nil or false - no effect.
Only way to disable is to touch somewhere else on the screen.
I realize that that is how the mouse reacts but it seems strange that when there is no touch contact that the last touch response would be retained.
Code: Select all
listbox.contact = function( x, y, w, h ) -- mouse over/clicked rectangle
local contact, hover
local mx, my = love.mouse.getPosition( )
if mx > x and my > y and mx < x+w and my < y+h then
hover = true
if love.mouse.isDown( 1 ) then contact = true end
end
return hover, contact
end
However, I found that it also works for Touch EXCEPT that if I touch within the area, it indicates that I am still hovering over it even after I remove my finger.
Is this expected behavior?
Is there a way to turn off hover when the touch is no longer in contact with the screen?
Tried setting hover, mx and my to nil or false - no effect.
Only way to disable is to touch somewhere else on the screen.
I realize that that is how the mouse reacts but it seems strange that when there is no touch contact that the last touch response would be retained.