Use InputProcessor to support shared mouse

This commit is contained in:
Arnaud Jamin
2023-11-24 09:46:03 -05:00
parent 1daa073713
commit ecddecf3e5
11 changed files with 80 additions and 187 deletions
@@ -51,18 +51,24 @@ void SCogImguiWidget::Construct(const FArguments& InArgs)
//--------------------------------------------------------------------
// Register input processor to forward input events to imgui
//--------------------------------------------------------------------
UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GameViewport->GetWorld());
InputProcessor = MakeShared<FImGuiInputProcessor>(PlayerInput, this);
FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor.ToSharedRef(), 0);
if (FSlateApplication::IsInitialized())
{
UPlayerInput* PlayerInput = FCogImguiInputHelper::GetPlayerInput(*GameViewport->GetWorld());
InputProcessor = MakeShared<FImGuiInputProcessor>(PlayerInput, this);
FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor.ToSharedRef(), 0);
}
}
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
//--------------------------------------------------------------------------------------------------------------------------
SCogImguiWidget::~SCogImguiWidget()
{
if (InputProcessor.IsValid())
if (FSlateApplication::IsInitialized())
{
FSlateApplication::Get().UnregisterInputPreProcessor(InputProcessor);
if (InputProcessor.IsValid())
{
FSlateApplication::Get().UnregisterInputPreProcessor(InputProcessor);
}
}
DestroyImGuiContext();