Skip to content

Commit

Permalink
Consume events only if imgui is any imgui control is active.
Browse files Browse the repository at this point in the history
Remove escape key handling in Console
  • Loading branch information
rokups committed Jun 16, 2017
1 parent 67b94a8 commit 3c3cfbd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions Source/Atomic/UI/SystemUI/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ void Console::SetVisible(bool enable)
SubscribeToEvent(E_SYSTEMUIFRAME, ATOMIC_HANDLER(Console, RenderUi));
}
else
{
UnsubscribeFromEvent(E_SYSTEMUIFRAME);
ImGui::SetWindowFocus(0);
}
}

void Console::Toggle()
Expand Down Expand Up @@ -230,12 +233,6 @@ void Console::RenderUi(StringHash eventType, VariantMap& eventData)

windowSize_.y_ = ImGui::GetWindowHeight();

if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(SCANCODE_ESCAPE))
{
SetVisible(false);
ImGui::SetWindowFocus(0);
}

ImGui::End();
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Atomic/UI/SystemUI/SystemUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void SystemUI::OnRawEvent(VariantMap& args)
case SDL_KEYUP:
case SDL_KEYDOWN:
case SDL_TEXTINPUT:
args[SDLRawInput::P_CONSUMED] = ImGui::IsAnyWindowFocused();
args[SDLRawInput::P_CONSUMED] = ImGui::IsAnyItemActive();
break;
case SDL_MOUSEWHEEL:
case SDL_MOUSEBUTTONUP:
Expand Down

0 comments on commit 3c3cfbd

Please sign in to comment.