Is Common UI Button interactable when selected broken?

I’m using a custom Class the inherits from UCommonButtonBase.
I’m trying to create this behavior:

  • the button can be toggled
  • the button cannot be toggled by clicking it when it is selected
  • the button is only toggled when i call Set Is Selected from another Event.

What I found is that I need Toggleabe property set to True. Otherwise the Select/Deselect behavior doesn’t work.

HOWEVER, when the button is Selected, I can still click and deselect it. That’s not the behavior I want.

There is a property called ‘Interactable when Selected’ and in the comment we can see it is intended to avoid the button being clickable when it is Selected.
But it does not work.
I can still click and Deselect the button.

So, is this a bug or I’m not doing something right?

2 Likes

Your use of the word “click” makes it sound like this is a mouse-only interaction, correct?
If you don’t want the mouse to be able to click something, you can usually set its visibility to not hit testable. I’m not sure if the same options are available in Common UI widgets though.

Alternately, you can put an image on top of the button by using a higher Z order and then setting the alpha for the image’s color to 0 so it is completely invisible, but the player mouse is unable to click the button.

Hi Detach, thanks for the reply.
Yes it is mouse interaction. The Non Hit-Testable works as a work around.
Right now Im using a similar approach that is kinda trick. Im setting the buttons to Not Toggable.

When I want to deselect a button (from another event) I set the button to Toggable. Then I change the select state and set to Not Toggable again.

  • I’ll use your Non-Hit Testable idea. the blueprint for this will give me a much cleaner solutions. thanks

Undigging, because it’s the only thread I can find about it.

My Setup is: I have a row of buttons, and there can be only one selected at the same time, and at least one must be selected at any time. So basically when you select something, the currently selected one deselects, and you can’t deselect by clicking again.

Judging by the tooltips, the “InteractableWhenSelected” was what I was looking for as well, but it’s not working as op mentioned.
So I peeked inside the code and I don’t now why, but basically whenever 'Interactable when Selected’ is checked, it also checks if Toggleable (one option below) is unchecked… It might be a bug, it might be a feature, I’m not digging into it, but it makes InteractableWhenSelected useless if you want to have a Toggleable Button, but not interactable.

My solution is similar to schmigel’s first one (because “not hit testable trick” doesn’t work for me, and I’m not itching to investigate it).
Turn everything Toggleable, and set it to not toggleable when it’s selected. When you want to deselect it with BP just unset Toggleable right before it

cheers

2 Likes

Further comments and a workaround for posterity:

I fought with this this morning and came to the same conclusion that “InteractableWhenSelected” and even “Toggleable” are not intuitively named or designed. I too have a set of four buttons and exactly one must be selected at all times. Toggleable must be true if you want to be able to deselect other buttons in blueprint. InteractableWhenSelected set to False however does not make the button non-interactable (and what it actually does is a mystery I haven’t dug into). Other solutions, like trying to shut off Toggleable when selected or making it non-hit testable when selected also didn’t work for unknown reasons.

Instead, I added a variable that tracked what button is selected (which I use anyway since in my case these are category buttons that filter a tile view). In On Selection Change, I check that selected category and if Selection Change is trying to deselect the button while the category is still the selected category then I reset it to selected. I abstracted this handling into a function so all of my buttons could call it, reselect themselves if needed, else deselect any other buttons (in my ResetCatSelection function), refilter the tile view, and save the updated category.

Making InteractableWhenSelected actually work on Toggleable buttons would be ideal but this now operates as expected.