How do you check if a button is focused or not with blueprint?

I want to implement a way to check if a button is focused or not, so it can play a animation when it is or not. But so far Unreal doesn’t have a action to see if something is focused or not. How do I make this work?

1 Like

You could try some of these:

My Products

I tried but I don’t really get any results from it

Could you provide more info?

It works with mouse hover but not with gamepad. It does work when I hold the interact button while scrolling though the menu. But normally it doesn’t

Try this, please:

image

1 Like

‘Event on Added to Focus Path’ its not what I’m searching for. It adds focus to the assignt item, but doesn’t do any actions for when it focus receives. And those actions can only be called once. How do I use those for multiple buttons?

You can wrap the button in a user widget and use it multiple times.

  1. Create a user widget and add a button to it. Then add needed dispatcher events:
    image

  2. Add this button wrapper to your widget and subscribe to its dispatcher events:

3 Likes

I feel like answered an identical question a couple of days ago. You wrap a button in a user widget and override:

image

There’s also Focus Lost event.

You then use those buttons in your interface. Since every button now has this, there’s little else to worry about.



edit: cross-posted with @Supremative :1st_place_medal:

2 Likes

What wrapper do I need?

Wrapper is a generic term - it’s not one thing - it’s another layer.

What we meant was:

  • put a button in a widget - this user widget is now your custom button
  • each custom button has a full graph, variables, functions, overrides, animations, dispatchers(!)
  • you no longer use native buttons, you use your custom buttons instead

image


You can, of course, add more things there. The best example above:

1 Like

Sorry I can’t really see how you got all those options in the second image

Once you get on board with this technique, you no longer need to do things manually (but you still can and may want, but it’s an option, not a must):

image

Rather than placing every event by hand, you can now:

Instead of 7 events, you now have one.

Make a new widget → add a button. instead of the buttons you were using before, use those new user widgets. Since every button is now a fully-fledged widget, it can:

Alright so I’m creating an Fucntion myself then. But I can’t really make it manage to work. The menu doesnt even open when I include this function.

But this is not your button, is it? This should be inside the button blueprint. Your HUD should be made of custom buttons and other fancy things. Each of the custom buttons has the ability to play its own animation when it receives focus. Focus Path may be a better option, depending on how other things are scripted.

Alright so I’m creating an Fucntion myself then.

It has to be an override.

1 Like

The project I’m working on has been deliverd like this. They made everything in one blueprint for the UI, even the menu I’m asking about. But your advice is to make an separate blueprint for the button?

Precisely. User widgets are the cornerstone of UI design.

1 Like