flamendless / Slab

An immediate mode GUI for the Love2D framework.
MIT License
285 stars 25 forks source link

Clicks get dropped at low framerate #102

Open megagrump opened 2 years ago

megagrump commented 2 years ago

Using love.mouse.isDown is not sufficient for reliable click detection. Clicks may occur between mouse sampling points and go unnoticed by the game/application. The lower the framerate, the higher the probability that this happens.

Solution: use love.mousepressed and love.mousereleased instead, and make sure the click event has an effect even when mousereleased gets called in the same frame as mousepressed.

flamendless commented 2 years ago

I'd probably leave this one for you as I don't have any idea how to solve this as i haven't yet experienced this issue in love 🤔

megagrump commented 2 years ago

You can test this by adding love.timer.sleep(.2) at the bottom of love.draw in main.lua. It's gonna be pretty difficult to click anything.

The same problem was apparently occuring in Keyboard.lua. The same solution would work for the mouse.

megagrump commented 2 years ago

This is now fixed for clicks, but still an issue when resizing a window at low framerates. Possibly other places too.