artursapek / mondrian

Web-based vector graphics editor
MIT License
1.24k stars 106 forks source link

Fails to recognize tablet pen tip "click" input. #10

Closed Fishrock123 closed 10 years ago

Fishrock123 commented 10 years ago

Ok so, this isn't about full tablet support. That would only be available via a plugin / extension.

I have an Intuos5 Digitizer tablet, and mondrian is not recognizing the click/mouseup event from the pen tip.

Fishrock123 commented 10 years ago

Funnily enough, the eraser tip works perfectly.

artursapek commented 10 years ago

Hahah. It seems like a hardware problem. Does the tablet's pen tip act as a mouse on other websites? I used to have an Intuos and I remember the computer just thinking it was a mouse.

Fishrock123 commented 10 years ago

Yes, without a special extension to the browser, it will.

I have been fooling around with event listeners for the past couple minutes and it seems to be recognized as a normal mouse.

artursapek commented 10 years ago

I have no idea, sorry. Don't have a way to try it myself.

If you figure out the problem you could fix it and open a PR. The code having to do with the cursor is here. It's a class that keeps the state of the cursor to achieve things like dragging and double-clicking. I may have done something to break your tablet there, but again if the computer just thinks it's a mouse I don't understand what would cause your mouse to work and your tablet to not.

Fishrock123 commented 10 years ago

Ok, I'm pretty sure a lot of this issue is caused by wonky double-click support. Still investigating.

Edit: Nope, it's the drag support that is messing with it.

An "easy" way to deal with this may be to disable drag support unless the tool uses it.

artursapek commented 10 years ago

How do you know it's the drag support? Were you able to fix it by disabling some code?

Fishrock123 commented 10 years ago

Dragging blocks clicks, and logging showed it was firing drag events.

This could probably be fixed by widening the minimum drag distance, or something.

artursapek commented 10 years ago

Oh, I get it. Yes. "Clicks" in Mondrian are:

  1. Mouse down
  2. Mouse up iff the mouse has not changed position

So your problem is it's hard to push down with a stylus without moving it at all.

I think you're right on. A minimum drag distance (2-3px) could help for tools that don't require dragging. You could also implement a slightly higher threshold for tools that don't need dragging.

This would obviously take some testing and adjusting. Since you're the one with the Intuos, if you get something working that feels good to you, I'd love to see it in a PR. :)

tomByrer commented 10 years ago

On my Sprint Samsung Note 2, I can open the webpage, open menu items, select boxes on the left, but can not 'draw'.

artursapek commented 10 years ago

You need to drag to draw, and dragging on phones is scrolling. There might be a way to get around this with JavaScript, but I don't have a tablet to test on yet.