GUI button with isReadOnly or isPointerBlocker

Dears,
I believe last time I checked I was able to use the above on a control or container.
This morning I wanted to use this behavior to temporarly block interactions but it wasn’t working.
As always, I first thought I did something wrong in my script :dizzy_face: :wink:. Finally, ended-up creating this very simple PG and surprise, it looks like these have no effect anymore.

Besides, I also noticed this helper when hovering the property, explaining that ‘isPointerBlocker’ is FALSE by default EXCEPT on buttons, radio, checkbox, input, slider… Where I believe, it’s likely the other way round, isn’t it?

Yep, it seems like this is not working as expected!

image

Not sure what “raise pointer events but not react to them” means, but i would expect the callback not to be executed.
I’ll see what we can do about it :slight_smile:

Oh, wait. I got it.

This is the correct behavior. The button animation does not trigger, but the events are being raised.

1 Like

Well, ok. Not sure why because ‘readOnly’ should be ‘readOnly’ the way I understand it.
But then if ‘isPointerBlocker’ would also act the same, how am I supposed to block my pointer (events) interactions? And I’m pretty sure (about 99%) I used this before for blocking events.

Oh, pointerBlocker means that pointer events will not bubble to the 3D scene.
What you can do is check for the button state in the callback you have defined and not react if it it sread only, or simply disable the button by setting ìsEnabled = false`

2 Likes

Thank you, yes. I believe ‘isEnabled’ is the one I used. Just forgot about it :wink:
The comment for the helper still remains though. I believe the word ‘except’ should be removed because I believe the controls listed are the ones that are no pointer blockers.

1 Like

OK @RaananW I might have marked it as a solution a bit too early. Although the solution with the button state callback would work, I’d like to understand why:

  1. When using the ‘isEnabled’ property, the control automagically turns grey.
  2. Why would a property named ‘isReadOnly’ set on a GUI element would still trigger a pointer event.
  3. Why would both ‘isPointerBlocker’ and ‘isReadOnly’ act the same in the aspect of pointer events.
    This is all not very clear to me. I hope it is for you, is it?

Always happy to answer :slight_smile:

  1. The GUI elements are a whole package, including default colors and other fun stuff (like the effect when you click on them)., The disabled state makes the button gray. You can change this behavior, of course, but this is what we (the team) thought would make sense when the button is disabled. similar to the way disabled button in HTML works.
  2. Good question! poor naming on our part TBH. what is meant by “isReadyOnly” is that the effects that happen when pointer events are raised (hover, leave, click and so on) or not influencing the button. Poor naming. BUT, since we support back-compat, we can’t really change it.
  3. They don’t. isPointerBlocker is not doing more than block the events to the 3D scene (or better yet “further down the event tree”). so if you have a button and a sphere behind it, and both have a pointer down callback registered, setting isPointerBlocker = true will not trigger the click on the sphere, if the button was clicked.
    Having said that if I misunderstood or if what i said is not truly the case, I will be happy to debug it! :slight_smile:

Thanks, your explanations are very good and overall make sense (as always :smiley:).
However, I still do not understand why there is nothing except a callback on a button state to simply block/stop all pointer events on a given control or container (except for isEnabled and next having to tweak this to make it so that it keeps with its color or to set the color I want). May be it’s just me.
Anyways I’m gonna use the callback and check state method for my case and for now.
Thanks again for your reply and for your dedication to our user experience and have a great day :sunglasses:

Edit: Forgot to say and I just thought about this: Since I didn’t use a button, but a rectangle and a textBlock and since the textBlock is actually a blocker by default and is on top of the container in the hierarchy, I think I’m gonna just twist this by making my tb the size of my container and set the tb to ‘isPointerBlocker’. How fancy is that? :grin:

2 Likes