Getting full pointer event info from gui2d control

Hi, is it possible to get the full DOM event info from a “pointerdown” event on a gui2D control? Currently I’m adding the event with control.onPointerDownObservable as stated here: Control - onPointerDownObservable
but I can only get a Vector2WithInfo that only has x, y and buttonIndex properties.

But for instance with scene.onPointerObservable you get access to the whole PointerInfo which provides the DOM Event object.

So, is it possible to get the full event info from a gui2D control “pointerdown” somehow? I’m particularly interested in the pointerType, ctrlKey and some other event properties.


You have it as the second parameter of the observable:

control.onPointerDownObservable.add((vec, pointerInfo) => {

I tried that on the first place as well, but that second parameter is a BABYLON.EventState and doesn’t seem to have the event properties as the PointerInfo object.

Here is a playground with the console out of this second parameter:

good catch, it is a bug! Will be fix in next nightly :smiley:

Thanks Deltakosh! But it may not be a bug and its just the way it is designed? In the docs it states that observable.add has two arguments in its callback which are an Eventdata and Eventstate. In the case of control.onPointerDownObservable.add these are the Vector2withInfo and the EventState. So it may be better to extend the Vector2withInfo with a property with he DOM event data or a pointerInfo? To not break backward compatibility

no worries, the eventState will come with the pointerInfo as well when the nightly will be deployed. It was really a bug :smiley:

Cool, thanks!