How to change the opacity of any button in a Widget, when hovering it ?

Hello,

I’d like to ask :
Does anyone have any solution to make any hovered button’s opacity 1 and all others 0,7, in a Widget ?

Here’s the way I do it :

Then, when I don’t hover it anymore, opacity goes back to 0,7.

Remark : The button’s background color is completely transparent, so I can change the button’s Color and Opacity’s Alpha, it’d do the same

Well, that’s for the basic buttons of the menu, but then, the Continue the Options buttons call a WidgetSwitcher and we have to do the same opacity handling stuff with many more buttons. In the end, the graph would be so long for a simple and repetitive task I can’t believe there is no better way to do it.

I could think of a few different solutions :

  • Widget’s Tick calling a ForEach (Button b in self) → change b’s opacity if Hovered.

  • Get Hovered element(s) in Widget, then cast the element(s) to button and change Opacity if cast done successful.

    For these two solutions, keep in mind that we have to reset the button’s opacity to 0,7 when Unhovered (with tick affecting 0,7 if not hovered or with temporary reference maybe).

  • Overriding/Redefining the On Hovered (and then On Unhovered the same way) event in Type Button (or only this Widget’s buttons if it’s possible) to change the button’s opacity On Hovered’s calling.

Thanks a lot !

PS : If it could help, here’s a part of the concerned elements my Widget Hierarchy (then there are also buttons in Resolution and in Keyboard)

259185-issue3.jpg

The easiest way is to Get all the Buttons > MakeArray > ForEachLoop > GetIsHovered > create a Branch > out of True Set Opacity to 1 > out of False Set Opacity to 0.7. Connect the execution to a Tick.

I think doing so much computation inside Tick should be avoided.
At least the “Get all the Buttons > MakeArray” part should be out of Tick, but it’s still far from optimal.

If I had to do it today, I’d probably create a new C++ class derived from Button and create delegate functions for OnHovered and OnUnhovered.
Then in the widget I’d use my custom buttons.

What about this:

Get all controls that are buttons, create an array out of them, bind to OnHovered Event for each of them; Whenever one is hovered, do your opacity thing with the array. Nothing is run on tick.

You’ll probably need to bind to OnUnhovered too to set the default opacity for everything.

Yeah, that’s a good solution !