CogImGui: Fix key down/up not properly sent to imgui

This commit is contained in:
Arnaud Jamin
2023-12-18 12:47:38 -05:00
parent 85a903a341
commit 829be00034
2 changed files with 13 additions and 12 deletions
@@ -122,17 +122,17 @@ FReply SCogImguiWidget::OnKeyChar(const FGeometry& MyGeometry, const FCharacterE
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) FReply SCogImguiWidget::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
{ {
return HandleKeyEvent(MyGeometry, KeyEvent); return HandleKeyEvent(MyGeometry, KeyEvent, true);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) FReply SCogImguiWidget::OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent)
{ {
return HandleKeyEvent(MyGeometry, KeyEvent); return HandleKeyEvent(MyGeometry, KeyEvent, false);
} }
//-------------------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------------------
FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent) FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down)
{ {
if (Context->GetEnableInput() == false) if (Context->GetEnableInput() == false)
{ {
@@ -152,8 +152,9 @@ FReply SCogImguiWidget::HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEv
{ {
return FReply::Unhandled(); return FReply::Unhandled();
} }
ImGuiIO& IO = ImGui::GetIO(); ImGuiIO& IO = ImGui::GetIO();
IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), false); IO.AddKeyEvent(FCogImguiInputHelper::ToImKey(KeyEvent.GetKey()), Down);
IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown()); IO.AddKeyEvent(ImGuiMod_Ctrl, KeyEvent.IsControlDown());
IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown()); IO.AddKeyEvent(ImGuiMod_Shift, KeyEvent.IsShiftDown());
IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown()); IO.AddKeyEvent(ImGuiMod_Alt, KeyEvent.IsAltDown());
@@ -53,7 +53,7 @@ public:
protected: protected:
FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent); FReply HandleKeyEvent(const FGeometry& MyGeometry, const FKeyEvent& KeyEvent, bool Down);
void RefreshVisibility(); void RefreshVisibility();