RealtimeStyleTransferRuntime/Source/LyraGame/UI/Foundation/LyraButtonBase.cpp

52 lines
1.0 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraButtonBase.h"
#include "CommonActionWidget.h"
void ULyraButtonBase::NativePreConstruct()
{
Super::NativePreConstruct();
UpdateButtonStyle();
RefreshButtonText();
}
void ULyraButtonBase::UpdateInputActionWidget()
{
Super::UpdateInputActionWidget();
UpdateButtonStyle();
RefreshButtonText();
}
void ULyraButtonBase::SetButtonText(const FText& InText)
{
bOverride_ButtonText = InText.IsEmpty();
ButtonText = InText;
RefreshButtonText();
}
void ULyraButtonBase::RefreshButtonText()
{
if (bOverride_ButtonText || ButtonText.IsEmpty())
{
if (InputActionWidget)
{
const FText ActionDisplayText = InputActionWidget->GetDisplayText();
if (!ActionDisplayText.IsEmpty())
{
UpdateButtonText(ActionDisplayText);
return;
}
}
}
UpdateButtonText(ButtonText);
}
void ULyraButtonBase::OnInputMethodChanged(ECommonInputType CurrentInputType)
{
Super::OnInputMethodChanged(CurrentInputType);
UpdateButtonStyle();
}