How can I enable pointer blocking for click events only? (and not scroll events)

Hello,

I’m using the GUI Button and I would like my button to register a click but pass any scroll events through to the scene below it.

Pseudo code of how I want to configure my button:

  const button = new BABYLON.GUI.Button()
  button.isPointerClickBlocker = true
  button.isPointerScrollBlocker = false

Can you think of a way I can achieve behavior like this?

Thanks!

cc @DarraghBurke ?

Thanks @sebavan & @DarraghBurke, I’m considering making my own custom button component to get round this but wanted to make sure there wasn’t a more ‘native’ babylon way to do it

Unfortunately scroll blocking is a little tricky to separate out from other types of pointer blocking. Any pointer event, including wheel, will be blocked if isPointerBlocker is true. We would need to add either a flag for scroll events or else some kind of custom event handling behavior in order to support this. This could potentially be a feature for after 5.0, but that would be a few months out at the earliest.

I think writing your own class which extends Button would be your best bet for the short term.

3 Likes

Thanks for the quick reply, I’ll give that a shot

2 Likes

Here’s how I ended up doing it, for some reason the playground wont run (some syntax error I can’t figure out) but this gave me the functionality I wanted. See the MyButton class:

2 Likes