瀏覽代碼

Disable text input on window deactivation

Ivan Savenko 2 年之前
父節點
當前提交
a75b437fef

+ 3 - 1
client/battle/BattleInterfaceClasses.cpp

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

+ 3 - 2
client/battle/BattleInterfaceClasses.h

@@ -55,12 +55,13 @@ private:
 	/// current text entered via in-game console, takes priority over both log entries and hover text
 	std::string consoleText;
 
-	/// if true then we are currently entering console text
+	/// if true then we are currently entering console tex
 	bool enteringText;
 public:
 	BattleConsole(const Rect & position);
-	~BattleConsole();
+
 	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)
 	void scrollUp(ui32 by = 1); //scrolls console up by 'by' positions

+ 8 - 0
client/widgets/TextControls.cpp

@@ -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)
 {
 	onClick = handler;

+ 1 - 0
client/widgets/TextControls.h

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