Download

UMG Simulate Button States and Click

It seems strange that you can’t simulate states on the UMG widgets since it’s needed to navigate menus and buttons with a gamepad.

The functions are in the Slate class, to set mouse enter and mouse leave. I thought that I could call those to set the hovered state. I can’t just set the background color because it’s an image for hovered, not just a color change. The functions require a FGeometry as input though, and there’s no reference to it.

Does anyone know of how to get a button’s geometry so can call functions on it that require it as arguments, such as OnMouseEnter()?

Turned out, it wasn’t needed. Who should believe function parameters. They weren’t needed. I passed in null.

I’ll leave this here, sure someone else wants to set and unset hovered state.

void USimButton::SimulationHover(bool newHover)
{
FPointerEvent ptrEvent;

if (newHover)
{
	MyButton->OnMouseEnter(NullGeometry, ptrEvent);
}
else
{
	MyButton->OnMouseLeave(ptrEvent);
}

}