Skip to content

Commit

Permalink
Close console when it loses focus but it is still on screen
Browse files Browse the repository at this point in the history
  • Loading branch information
EXio4 authored and kahrl committed Jun 5, 2013
1 parent 4f6bec1 commit 7cb5217
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/game.cpp
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/guiChatConsole.cpp
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/guiChatConsole.h
Expand Up @@ -39,6 +39,9 @@ class GUIChatConsole : public gui::IGUIElement
// 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;
Expand Down

0 comments on commit 7cb5217

Please sign in to comment.