Close console when it loses focus but it is still on screen
authorEsteban I. Ruiz Moreno <exio4.com@gmail.com>
Wed, 5 Jun 2013 02:26:52 +0000 (23:26 -0300)
committerKahrl <kahrl@gmx.net>
Wed, 5 Jun 2013 19:14:14 +0000 (21:14 +0200)
src/game.cpp
src/guiChatConsole.cpp
src/guiChatConsole.h

index 22bd8c4292fbb02f55d8d9b715500c6d5cb7fd74..2d43d05b8af697cf85f88bee560136e935756264 100644 (file)
@@ -1684,6 +1684,10 @@ void the_game(
                {
                        input->clear();
                }
+               if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen())
+               {
+                       gui_chat_console->closeConsoleAtOnce();
+               }
 
                // Input handler step() (used by the random input generator)
                input->step(dtime);
index 3dfd0090a6c6b224898b06ed678ec41269f33eb8..c1219fb808c29fe535e01b3267b5e7c4070f8444 100644 (file)
@@ -134,6 +134,11 @@ void GUIChatConsole::openConsole(f32 height)
        reformatConsole();
 }
 
+bool GUIChatConsole::isOpen() const
+{
+       return m_open;
+}
+
 bool GUIChatConsole::isOpenInhibited() const
 {
        return m_open_inhibited > 0;
index c896aae28d6caa5fd17efc7f0313077afad1e0ab..5991157b276bc06003f8c5b4c6bbc622655fd2bd 100644 (file)
@@ -39,6 +39,9 @@ public:
        // This doesn't open immediately but initiates an animation.
        // You should call isOpenInhibited() before this.
        void openConsole(f32 height);
+
+       bool isOpen() const;
+
        // Check if the console should not be opened at the moment
        // This is to avoid reopening the console immediately after closing
        bool isOpenInhibited() const;