RealtimeStyleTransferRuntime/Source/LyraGame/UI/Common/LyraBoundActionButton.cpp

43 lines
940 B
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraBoundActionButton.h"
2022-09-13 07:18:28 +00:00
2022-05-23 18:41:30 +00:00
#include "CommonInputSubsystem.h"
2022-09-13 07:18:28 +00:00
#include "Delegates/Delegate.h"
class UCommonButtonStyle;
2022-05-23 18:41:30 +00:00
void ULyraBoundActionButton::NativeConstruct()
{
Super::NativeConstruct();
if (UCommonInputSubsystem* InputSubsystem = GetInputSubsystem())
{
InputSubsystem->OnInputMethodChangedNative.AddUObject(this, &ThisClass::HandleInputMethodChanged);
HandleInputMethodChanged(InputSubsystem->GetCurrentInputType());
}
}
void ULyraBoundActionButton::HandleInputMethodChanged(ECommonInputType NewInputMethod)
{
TSubclassOf<UCommonButtonStyle> NewStyle = nullptr;
if (NewInputMethod == ECommonInputType::Gamepad)
{
NewStyle = GamepadStyle;
}
else if (NewInputMethod == ECommonInputType::Touch)
{
NewStyle = TouchStyle;
}
else
{
NewStyle = KeyboardStyle;
}
if (NewStyle)
{
SetStyle(NewStyle);
}
}