Simulate Button Press Visuals

Hello!
I’m working on a project and wish to have keybinds and UI buttons be able to perform the same thing.

While I have hooked up an event to call the same thing the UI button does, is there a way to make it play the ‘pressed’ visual on the keybind hotkey being pressed?

For instance: Say I have an ability key for throwing a grenade. If you use the mouse to click on it on the UI you get the ‘pressed’ visual while you hold the mouse button down, then it returns to normal when you release the mouse button.
I want those same visuals to occur when pressing the keybind tied to that UI element, but I’m uncertain if there’s a simple way to do that.

Doing this in an RTS-style setup, so I don’t want to ‘steal the mouse over to the key for just a frame to simulate the press’ or anything, either.
The player also will not be ‘navigating’ the buttons, so I don’t think UE4’s “Focusable” feature is an option, but let me know if there’s a way to do that.

Did you ever managed to find a solution? I am looking to solve the exact same problem.

I was looking to do this with a gamepad and ui elements, so I just set the style of my button whenever I wanted it to happen.

image

Here’s a hacky way to do this in C++

FButtonStyle style = ConfirmButton->GetStyle();
FSlateBrush PressedDownStyle = ConfirmButton->GetStyle().Pressed;
style.SetNormal(PressedDownStyle);
ConfirmButton->SetStyle(style);

And if you don’t have it already, you’ll have to add “Slate” and “SlateCore” into your Build.cs PublicDependencyModuleNames

I have this on a confirm button in a popup widget that opens/closes. Upon re-opening the widget, the style is reset to normal with no additional code. If you have a widget that stays open after this code is run, you’ll likely have to set the Normal style back to Normal.