UButton set isHovered

Hi,

is it possible to set the isHovered bool of a button to true without hovering with your mouse?
if so can you explain how?

thanks in advance,

On UMG level you can’t, IsHovered is not varable to begin with, it’s a function that ask Slate widget if it’s hovered (If you didn’t noticve UMG is just Blueprint wrapper for Slate, UMG classes practically only operate Slate widgets, they not widgets from themselves):

bool UWidget::IsHovered() const
{
	TSharedPtr<SWidget> SafeWidget = GetCachedWidget();
	if (SafeWidget.IsValid())
	{
		return SafeWidget->IsHovered();
	}

	return false;
}

you can’t even override this function because it’s not virtual, you need to think of some workaround. You didn’t explained why you want to do it, so whatever you trying to do study code of UWidget and UButton and oyu may try to alter it’s behavior by creating class from UButton but remember that you can only override virtual function (once with V icon in API reference)

On other hand you could on Slate level it is possible, because bIsHovered is varable and IsHovered function just forward value of it.

Problem is bIsHovered is protected so you can’t change it from foreign class like UMG class, you would need to create Slate widget based of SButton and then create UMG widget for it to be able to use it in widget blueprints. And IsHovered function in slate is virtual so you don’t need to change varable just override a function.

But i bet there some less invasive workaround for that you trying to do

Hi

is it maybe possible to trigger to hoveredStyle of a button or set the hovered style on the normal style and back when “unhovered”?

im working on a way to use gamepads instead of a mouse without having a mouse cursor controlled by gamepads.

thanks in advance,