W3C home > Mailing lists > Public > public-pointer-events@w3.org > January to March 2013

Re: pointerType extensibility

From: Rick Byers <rbyers@google.com>
Date: Tue, 19 Feb 2013 10:13:45 -0500
Message-ID: <CAFUtAY9aGpL87pQbyVK4EH7ONvUxDJpWmpqx4vV_AahPxHnuew@mail.gmail.com>
To: "brandon.wallace@yahoo.com" <brandon.wallace@yahoo.com>
Cc: François REMY <francois.remy.dev@outlook.com>, Pointer Events WG <public-pointer-events@w3.org>
On Saturday, February 16, 2013, wrote:

> Using instanceof is a bit more tedious than accessing a pointerType
> property.  With instanceof,an author is reduced to writing a string of
> if/else statements.  A pointerType property gives authors several options:
> if/else statements, switch statements, virtual dispatch tables, etc.
>

I think that's true of any solution to this problem right?  I.e. it's
strictly simpler when an event has exactly ONE type, but that's exactly the
problem for extensibility.


> Pure OO designs work best when the different functionality can be captured
> in overridden virtual methods and the client code doesn't need to actually
> know the concrete type.  Its usefulness starts to decline when knowing the
> actual type of object you have is important.
>

Agreed.  We talked on the call about having properties, eg. 'isCoarse',
'supportsHover', etc.  Perhaps this is the right long-term direction.
 Jacob argued that those properties would probably map exactly to
'isTouch', 'isMouse' and 'isPen' and so it was technically identical while
being conceptually more complex.


> Also, this approach is limited to single inheritance.  When a new device
> comes out, it may make sense for it to masquerade as more than one type of
> legacy device.  This would not be possible.
>

Agreed - as you say the separate bits are better in this respect.  But I
doubt any future device would choose to do this since the impact on
compatibility would be inconsistent and hard to predict (would now depend
on what order existing code checked for the previously mutually-exclusive
choices).


> --
> Brandon
>
> On Feb 15, 2013, at 2:51 PM, François REMY <francois.remy.dev@outlook.com<javascript:_e({}, 'cvml', 'francois.remy.dev@outlook.com');>>
> wrote:
>
> 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 Tuesday, 19 February 2013 15:14:17 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:17:04 GMT