Skip to content

Allow pointer events to be used if supported#1810

Open
adroitwhiz wants to merge 1 commit into
paperjs:developfrom
adroitwhiz:pointer-events
Open

Allow pointer events to be used if supported#1810
adroitwhiz wants to merge 1 commit into
paperjs:developfrom
adroitwhiz:pointer-events

Conversation

@adroitwhiz

Copy link
Copy Markdown
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)

Comment thread src/view/View.js Outdated

@lehni lehni left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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

lehni commented May 25, 2020

Copy link
Copy Markdown
Member

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

@adroitwhiz

Copy link
Copy Markdown
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
Copy Markdown
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

danrha commented Dec 27, 2021

Copy link
Copy Markdown

Would this potentially fix #1959?

@eeropic

eeropic commented Mar 25, 2022

Copy link
Copy Markdown
Member

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

@CallMeTuesday

Copy link
Copy Markdown

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

zalo commented Aug 8, 2023

Copy link
Copy Markdown

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