onPointerUp and friends vs. onPointerObservable : current recommendations?

I hope I didn’t read the official documentation too quick…

I ran today into a quite old forum comment from @RaananW here where Raanan wrote that onPointerUp is technically deprecated.

To this day, I still use this syntax over Observables sometimes, typically when it results in cleaner code.

Should I strive for systematically using the Observables pattern nowadays?
And while I’m at it: is there any performance difference between the two approaches? (I’m thinking in particular when events are fired at high frequency e.g. pointer movement events.)

Thanks!

We never really deprecated it, but we did provide a better API. As we guaranty backwards-compatibility, those APIs will stay there for as long as you use the current packages we provide.

We recommend using the observables, as we believe this is the better architecture for your application. One of the reasons is that by setting onPointerUp you are changing the babylon context (adding a function to the BABYLON namespace), whereas when you use observables you attach yourself to an already-existing observable.

But, eventually - use whatever you feel fits your application. Those function definitions will not be removed from the scene :slight_smile:

2 Likes

What’s the status of onPointerDown (observable), are all browser now returning it? Thx,

1 Like

Are there any issues with onPointerDown?

Back in 2018-9, there was. I remember having an exchange with @Deltakosh back then. So, I left it out but I have to admit I never tried again since. That’s why I’m asking. Obviously, I understand from your answer that everything should be fine now? :smiley:

We wouldn’t have survived that long without an onPointerDown support :slight_smile:

All should work as expected. And if you know what the issues was and can check it would be great

Apple can survive a decade without fixing major issues :wink: :face_with_open_eyes_and_hand_over_mouth:

2 Likes

Great, thanks for the update! :slight_smile:

I was trying to find this (very) old post but it must have been part of something else. If I (automagically :wink: find it again, I’ll let you know.

Luckily I prefer other fruits :slight_smile:

1 Like

@RaananW I noticed that when using a gui element and webxr on the device,
GuiElement.onPointerDownObservable triggers naturally and provides info needed to do things.
GuiElement.onPointerMoveObservable does not actually trigger.

I’m trying to use these in the buttons as listeners instead of implementing the controllers manually and recreating an event system that probably already exists…
have any suggestions?

Actually… I tested InputText and it worked… InputTextArea is broken??? referring to onmoveobservable not being triggered by XR controllers

Borrowing code from InputText and using it in InputTextArea seemed to work, I did it sloppy though, via overriding, but it definitely seems like a bug.

In the meantime, I also noticed that the only Button press even that is fired is the trigger press.
Is there a way to get grib press, other buttons and register them properly with the Observer system that babylons GUI uses? I’m trying to avoid manually handling events.

would you be able to reproduce the issue on a playground? If it is a bug i will be happy to squash it