Browse Source

Consume events only if imgui is any imgui control is active.
Remove escape key handling in Console

Rokas Kupstys 8 years ago
parent
commit
3c3cfbd125
2 changed files with 4 additions and 7 deletions
  1. 3 6
      Source/Atomic/UI/SystemUI/Console.cpp
  2. 1 1
      Source/Atomic/UI/SystemUI/SystemUI.cpp

+ 3 - 6
Source/Atomic/UI/SystemUI/Console.cpp

@@ -73,7 +73,10 @@ void Console::SetVisible(bool enable)
         SubscribeToEvent(E_SYSTEMUIFRAME, ATOMIC_HANDLER(Console, RenderUi));
         SubscribeToEvent(E_SYSTEMUIFRAME, ATOMIC_HANDLER(Console, RenderUi));
     }
     }
     else
     else
+    {
         UnsubscribeFromEvent(E_SYSTEMUIFRAME);
         UnsubscribeFromEvent(E_SYSTEMUIFRAME);
+        ImGui::SetWindowFocus(0);
+    }
 }
 }
 
 
 void Console::Toggle()
 void Console::Toggle()
@@ -230,12 +233,6 @@ void Console::RenderUi(StringHash eventType, VariantMap& eventData)
 
 
     windowSize_.y_ = ImGui::GetWindowHeight();
     windowSize_.y_ = ImGui::GetWindowHeight();
 
 
-    if (ImGui::IsWindowFocused() && ImGui::IsKeyPressed(SCANCODE_ESCAPE))
-    {
-        SetVisible(false);
-        ImGui::SetWindowFocus(0);
-    }
-
     ImGui::End();
     ImGui::End();
 }
 }
 
 

+ 1 - 1
Source/Atomic/UI/SystemUI/SystemUI.cpp

@@ -171,7 +171,7 @@ void SystemUI::OnRawEvent(VariantMap& args)
     case SDL_KEYUP:
     case SDL_KEYUP:
     case SDL_KEYDOWN:
     case SDL_KEYDOWN:
     case SDL_TEXTINPUT:
     case SDL_TEXTINPUT:
-        args[SDLRawInput::P_CONSUMED] = ImGui::IsAnyWindowFocused();
+        args[SDLRawInput::P_CONSUMED] = ImGui::IsAnyItemActive();
         break;
         break;
     case SDL_MOUSEWHEEL:
     case SDL_MOUSEWHEEL:
     case SDL_MOUSEBUTTONUP:
     case SDL_MOUSEBUTTONUP: