1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

Disable text input on window deactivation

This commit is contained in:
Ivan Savenko 2022-12-19 22:06:01 +02:00
parent d29c9d6445
commit a75b437fef
4 changed files with 15 additions and 3 deletions

View File

@ -113,10 +113,12 @@ BattleConsole::BattleConsole(const Rect & position)
pos.h = position.h; pos.h = position.h;
} }
BattleConsole::~BattleConsole() void BattleConsole::deactivate()
{ {
if (enteringText) if (enteringText)
setEnteringMode(false); setEnteringMode(false);
CIntObject::deactivate();
} }
void BattleConsole::setEnteringMode(bool on) void BattleConsole::setEnteringMode(bool on)

View File

@ -55,12 +55,13 @@ private:
/// current text entered via in-game console, takes priority over both log entries and hover text /// current text entered via in-game console, takes priority over both log entries and hover text
std::string consoleText; std::string consoleText;
/// if true then we are currently entering console text /// if true then we are currently entering console tex
bool enteringText; bool enteringText;
public: public:
BattleConsole(const Rect & position); BattleConsole(const Rect & position);
~BattleConsole();
void showAll(SDL_Surface * to) override; void showAll(SDL_Surface * to) override;
void deactivate() override;
bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters) bool addText(const std::string &text); //adds text at the last position; returns false if failed (e.g. text longer than 70 characters)
void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions

View File

@ -432,6 +432,14 @@ void CGStatusBar::clickLeft(tribool down, bool previousState)
} }
} }
void CGStatusBar::deactivate()
{
if (enteringText)
setEnteringMode(false);
CIntObject::deactivate();
}
void CGStatusBar::setOnClick(std::function<void()> handler) void CGStatusBar::setOnClick(std::function<void()> handler)
{ {
onClick = handler; onClick = handler;

View File

@ -152,6 +152,7 @@ public:
void setOnClick(std::function<void()> handler); void setOnClick(std::function<void()> handler);
void show(SDL_Surface * to) override; void show(SDL_Surface * to) override;
void deactivate() override;
// IStatusBar interface // IStatusBar interface
void write(const std::string & Text) override; void write(const std::string & Text) override;