nurpax / petmate

PETSCII editor with Electron/React/Redux
MIT License
185 stars 14 forks source link

mouse drawing drag end doesn't always get detected correctly #45

Closed nurpax closed 6 years ago

nurpax commented 6 years ago

Sometimes "draw draw" (e.g., draw with mouse button pressed down) doesn't release the mouse down state and keeps drawing even if I'm not pressing the mouse button.

I think this repros by moving the cursor out of the framebuffer area and doing "something" (maybe click a button on the left menu).

Viza74 commented 6 years ago

Yes, this happened to me too. Unfortunately I can't provide repro neither. :( ...but maybe connected to the brush drawing somehow?... I felt that this happened after interacting with the brush tool menu?... Not sure though.

nurpax commented 6 years ago

i think it happens when you drag (draw, colorize, brush) and click something else (eg. toolbar)

Viza74 commented 6 years ago

Ok, I got repro on this: Happens when the mouse release event is happening outside of the canvas. So just start drawing on the canvas, mose the mouse outside, the release the button. The program will act as if the mouse is held down anytime you move the cursor back over the canvas. You don't have to click any button or whatever outside the canvas. In fact you can do anything (change color, or tool) and it will stay in mouse down mode over the canvas.

So the program probably just waiting for mouse up on the canvas, which never arries.

nurpax commented 6 years ago

probably need to use mouse capture w/ pointer events to fix this. would like this for large brush drawing too

https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture

See also https://github.com/nurpax/petmate/issues/1