Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pointer events to be used if supported #1810

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

adroitwhiz
Copy link
Contributor

Description

This PR adds support for using pointer events instead of mouse/touch events if supported in the browser.

Previously, paper.js was testing for pointer event support by checking navigator.pointerEnabled, but that was removed from the pointer events spec back in 2013 and no longer implemented in modern browsers. Now it tests for the existence of window.PointerEvent.

Related issues

Checklist

  • New tests added or existing tests modified to cover all changes
    • This kind of thing is next to impossible to test automatically...
  • Code conforms with the JSHint rules (npm run jshint passes)

src/view/View.js Outdated Show resolved Hide resolved
Copy link
Member

@lehni lehni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change, then good to go. Thanks!

@adroitwhiz adroitwhiz requested a review from lehni May 23, 2020 23:29
@adroitwhiz
Copy link
Contributor Author

One other thing: Pointer events seem to break UI code that expects mouse events. Should pointer events have to be explicitly enabled, or should there be a version bump of some sort, to indicate that this may change applications' behavior?

@lehni
Copy link
Member

lehni commented May 25, 2020

@adroitwhiz could you explain how they break things? I don't quite understand the problem

@adroitwhiz
Copy link
Contributor Author

If there's external code that expects you to click on a canvas (e.g. an eyedropper tool, or dropdown that is supposed to close when you click on another element), for some reason it won't receive those "click" events if pointer events are enabled. I ran into this when testing out this change on a real-world codebase.

@adroitwhiz
Copy link
Contributor Author

Looks like the "pointer events break mouse events" behavior was talked about a bit here.

@lehni lehni force-pushed the develop branch 2 times, most recently from 39b63a1 to b90a711 Compare June 19, 2020 17:45
@lehni lehni force-pushed the develop branch 3 times, most recently from 4a6bf6f to 0f4afc5 Compare June 22, 2020 13:18
@danrha
Copy link

danrha commented Dec 27, 2021

Would this potentially fix #1959?

@eeropic
Copy link
Member

eeropic commented Mar 25, 2022

@danrha yes I think so. I'm doing this same change locally for easier differentiation between stylus, touch and mouse inputs

@CallMeTuesday
Copy link

What is the status with this PR @lehni? We've run into an issue that requires pointer support, a drawing app for use with iPad and Wacom tablets that are listening for pointer events (eyedropper, drawing, etc). Any chance we can get this pushed?

@zalo
Copy link

zalo commented Aug 8, 2023

I've found that the window.PointerEvent check doesn't work in modern Chrome on Windows, but "onpointerdown" in window appears to work well.

I've needed this to get the pointerId to enable setPointerCapture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pen tablets don't register mouse events on Firefox 59 + Windows 10
6 participants