RE: pointerType extensibility

This is probably a good idea. 

 

 


De : Rick Byers
Envoyé : ‎15‎ ‎février‎ ‎2013 ‎19‎:‎55
À : François REMY
Cc : Pointer Events WG
Objet : Re: pointerType extensibility


We agreed on the PE call that this was probably something we could address in V2 (although it might mean pointerType becomes deprecated and inaccurate), and so it shouldn't block going to LCWD.



Since we've already started the discussion (even if we may leave it unfinished until V2), let me try one other proposal that should feel more natural from an OO design perspective.  Instead of have a pointerType field at all, why not just use the type of the event object itself to signal pointer type, and encourage use of 'instanceof' checks.  For the most part people would program to the PointerEvent interface, but they could do, eg. 'instanceof TouchPointerEvent', and in the future browsers (and libraries?) could add, eg. DepthCamPointerEvent and have it derive from TouchPointerEvent.




I know this pure OO approach isn't normally how we design web APIs, but this is a traditional OO extensibility problem we're trying to solve.




Rick


On Tuesday, February 12, 2013, François REMY wrote:

> if (e.isPointerType('depth-cam')) {
> ... light up additional 3-d features
> } else if (e.isPointerType('touch') {
> ... definitely a non-depth-cam touch device
> }
>
> Since we probably only care about JavaScript, it's simpler and I think
> just as powerful to define a set of boolean read-only properties on the
> event, eg. PointerEvent.isMouse, PointerEvent.isTouch, etc.

I agree, a set of boolean properties would be nice. It allows for pointer types that inherit from older ones.

Received on Friday, 15 February 2013 20:52:06 UTC