mirror of
https://github.com/kevinporetti/UnrealImGui.git
synced 2025-01-19 00:40:32 +00:00
5968c3ce84
- Added ImGui Input Handler class that allows to customize handling of the keyboard and gamepad input. - Added ImGui Settings to allow specify custom input handler implementation. - Added editor support for ImGui Settings. - Input handling in ImGui Widget is divided for querying the handler (more customizable) and actual input processing based on the handler’s response (fixed and simplified). - Removed a need for checking console state in different input handling functions in ImGui Widget by suppressing keyboard focus support when console is opened.
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
// Distributed under the MIT License (MIT) (see accompanying LICENSE file)
|
|
|
|
#include "ImGuiPrivatePCH.h"
|
|
|
|
#include "ImGuiSettings.h"
|
|
|
|
|
|
UImGuiSettings::UImGuiSettings()
|
|
{
|
|
#if WITH_EDITOR
|
|
RegisterPropertyChangedDelegate();
|
|
#endif
|
|
}
|
|
|
|
UImGuiSettings::~UImGuiSettings()
|
|
{
|
|
#if WITH_EDITOR
|
|
UnregisterPropertyChangedDelegate();
|
|
#endif
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
void UImGuiSettings::RegisterPropertyChangedDelegate()
|
|
{
|
|
if (!FCoreUObjectDelegates::OnObjectPropertyChanged.IsBoundToObject(this))
|
|
{
|
|
FCoreUObjectDelegates::OnObjectPropertyChanged.AddUObject(this, &UImGuiSettings::OnPropertyChanged);
|
|
}
|
|
}
|
|
|
|
void UImGuiSettings::UnregisterPropertyChangedDelegate()
|
|
{
|
|
FCoreUObjectDelegates::OnObjectPropertyChanged.RemoveAll(this);
|
|
}
|
|
|
|
void UImGuiSettings::OnPropertyChanged(class UObject* ObjectBeingModified, struct FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
if (ObjectBeingModified == this)
|
|
{
|
|
static const FName ImGuiInputHandlerPropertyName = GET_MEMBER_NAME_CHECKED(UImGuiSettings, ImGuiInputHandlerClass);
|
|
|
|
const FName UpdatedPropertyName = PropertyChangedEvent.MemberProperty ? PropertyChangedEvent.MemberProperty->GetFName() : NAME_None;
|
|
if (UpdatedPropertyName == ImGuiInputHandlerPropertyName)
|
|
{
|
|
OnImGuiInputHandlerClassChanged.Broadcast();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif // WITH_EDITOR
|